Question

Build a list by asking the user to enter names until the user enters done. # Build a list which contains all numbers divisi

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

Code:

#a)
l = []
while input('Enter c to continue entering names in list , to quit enter done: ') != 'done':
    n = input("Enter name: ")
    l.append(n)

print("Final List: ", l)
#b)
lb = []
for i in range(1, 100):
    if i % 3 == 0:
        lb.append(i)

print("Numbers divisible by 3: ", lb)
#c)
le = []
for i in range(1, 150):
    if i % 2 == 0:
        le.append(i)
print("List of even numbers: ", le)

#d
lnm = []
for i in range(-10, 10+1):
    if i != 0:
        lnm.append(i)

print("List of numbers in range -10 to 10 without 0: ", lnm)

Output:

Enter c to continue entering names in list , to quit enter done: c
Enter name: shivam
Enter c to continue entering names in list , to quit enter done: c
Enter name: nichole
Enter c to continue entering names in list , to quit enter done: done
Final List: ['shivam', 'nichole']
Numbers divisible by 3: [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]

List of even numbers: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148]
List of numbers in range -10 to 10 without 0: [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Add a comment
Know the answer?
Add Answer to:
Build a list by asking the user to enter names until the user enters "done". #...
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 keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • using c++ write a program that reads numbers from the user until the user enters a...

    using c++ write a program that reads numbers from the user until the user enters a Sentinel. Use a Sentinel of -999. Ignore all negative numbers from the user input. Do the following: 1. Output the sum of all even numbers

  • C++ Write a program that prompts the user to enter integers or a sentinel to stop....

    C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

  • Using Python, write a program that keeps asking the user for text until they type "exit"...

    Using Python, write a program that keeps asking the user for text until they type "exit" To Exit Or Not Write a program that keeps asking the user for text until they type "exit" Console 1 Enter number 1 3 Enter number 5 5 Enter number 7 Enter number 8 1 9 Enter number 10 9 11 Enter number 12 3 13 Enter number 14 4 15 Enter number 16 exit 17 Bye! 18

  • IN PYTHON write a program that asks the user to enter 10 numbers and store them...

    IN PYTHON write a program that asks the user to enter 10 numbers and store them in the list and then find the followings: • Maximum • Minimum prime numbers in the list • even numbers in the list • odd numbers in the list.

  • Write a SIMPLE JAVA program to store a positive number a user inputs until he enters 0. Print all the numbers entered at...

    Write a SIMPLE JAVA program to store a positive number a user inputs until he enters 0. Print all the numbers entered at the end. The dialog might look like: Enter Number: 1 Enter Number: 10 Enter Number: 0 You entered numbers 1, 10

  • Write a method that asks the user to enter a list of names and ages using...

    Write a method that asks the user to enter a list of names and ages using Gui input and splits the info into an array of String. Validate that every other string is an int and check the value to ensure it is between 21 and 65 inclusive, print a message to the standard error object if not. Return the array. Use regular expressions to split and validate. Must follow java conventions and indent. In java with good indentations please

  • Allow the user to enter a list of movie titles until typing "Done". Add each movie...

    Allow the user to enter a list of movie titles until typing "Done". Add each movie title to a vector. After populating the vector, print all the titles. Then, remove from the vector all the titles from the list that include the word "the" (or "The") in its title and print the remaining titles. Sample Input: Captain Marvel The Lego Movie 2 Aladdin The Dark Knight Ant-Man and the Wasp Done Sample Output: Initial List: Captain Marvel The Lego Movie...

  • In this assignment we are asking the user to enter two number values, the starting and...

    In this assignment we are asking the user to enter two number values, the starting and ending numbers for our application. Having these values, we then construct a loop that will increment by one (1) from the starting number through (and including) the ending number. Within this loop we will check the current value of our number to see if it is evenly divisible by 3, then by 5, and then by both 3 and 5. We will output all...

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
ADVERTISEMENT