Question

Write a Python program that prompts the user to enter integer values for each of two...

Write a Python program that prompts the user to enter integer values for each of two lists. It then should displays whether the lists are of the same length, whether the elements in each list sum to the same value, and whether there are any values that occur in both lists.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# take input
L1 = input('Enter the values of first list space separated: ').split()
L1 = [int(x) for x in L1]
L2 = input('Enter the values of second list space separated: ').split()
L2 = [int(x) for x in L2]
# same length logic
if len(L1)== len(L2):
print("Both list are of same length")
else:
print("lists are of different length")
# equal sum check
if sum(L1)== sum(L2):
print("Both list have same sum value")
else:
print("lists have different sum")# find intersection b/w list
intersect = []
for x in L1:
if x in L2:
intersect.append(x)
intersect

if(len(intersect)==0):
print("Both list does not contain any common value: ")
else:
print("common values in both list are:")
for x in intersect:
print(x,)

Add a comment
Know the answer?
Add Answer to:
Write a Python program that prompts the user to enter integer values for each of two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write a python program that allows the user to enter two integer values, and displays the...

    write a python program that allows the user to enter two integer values, and displays the results when each of the following arithmetic operators are applied

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter...

    Python 3 **11.40 (Guess the capitals) Write a program that repeatedly prompts the user to enter a capital for a state. Upon receiving the user input, the program reports whether the answer is correct. Assume that 50 states and their capitals are stored in a two- dimensional list, as shown in Figure 11.13. The program prompts the user to answer all the states’ capitals and displays the total correct count. The user’s answer is not case sensitive. Implement the program...

  • Write a program that prompts the user to enter an integer and checks whether the number...

    Write a program that prompts the user to enter an integer and checks whether the number is divisible by both 5 and 6, divisible by 5 or 6, or just one of them (but not both). SAMPLE OUTPUT Enter an integer: 10 Is 10 divisible by 5 and 6? False Is 10 divisible by 5 or 6? True Is 10 divisible by 5 or 6, but not both? True (Python programming language)

  • I need to Write a test program that prompts the user to enter 10 double values...

    I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...

  • (PYTHON) Write a program that prompts the user to enter the number of students and each student's score

    USE PYTHON 3Write a program that prompts the user to enter the number of students and each student's score, and displays the highest and second- highest scores.

  • (Python Programming)Write a Python program that prompts the user to enter a list of words and...

    (Python Programming)Write a Python program that prompts the user to enter a list of words and stores in a list only those words whose first letter occurs again within the word (for example, 'Baboon'). The program should display the resulting list.

  • IN JAVA 1. Create a program that prompts the user for an integer and then displays...

    IN JAVA 1. Create a program that prompts the user for an integer and then displays a message indicating whether or not the number is a perfect square. This can be determined by finding the square root of a number, truncating it (by casting the double result), and then squaring that result 2. Write a program that prompts the user for two numbers. The first number is a minimum value and the second number is a maximum value. RandomNum then...

  • Using Python, write a program that prompts the user to enter their age as an integer...

    Using Python, write a program that prompts the user to enter their age as an integer and then prints out a message that says I suspect you were born in the year xxxx where "xxxx" is the current year minus the age entered. An example run where the user entered 10 for their age, would look like this: Please enter your age as an integer: 10 I suspect you were born in 2009

  • 1) Write a Python program that prompts the user to enter the current month name and...

    1) Write a Python program that prompts the user to enter the current month name and prints the season for that month. Hint: If the user enters March, the output should be "Spring"; if the user enters June, the output should be "Summer". 2 )Write a Python program using the recursive/loop structure to print out an equilateral triangle below (double spacing and one space between any two adjacent asterisks in the same row).          *      * * * *...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT