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]
Build a list by asking the user to enter names until the user enters "done". #...
Write a java program that keeps asking the user to enter a number until the user quits and prints how many even and how many odd numbers entered by the user. The loop terminates if the user enters -1 (it indicates that there will be no more number entering by the user). In other words, as long as the user doesn’t enter -1, the loop will be executed. Please add comments to the program to understand/ explain the code.
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...
Please Use Python Check the example codes of prompting the user for a list of numbers and prints out the maximum and minimum of the numbers at the end when the user enters “done”. Write the program to store the numbers the user enters in a list and use proper Python build-in functions or loops to compute the maximum and minimum numbers after the loop completes. Example output: Enter a number: 6 Enter a number: 2 Enter a number: 9...
Exercise 1: Write a program which repeatedly reads numbers until the user enters "done". Once "done" is entered, print out the total, count, and average of the numbers. If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next number. Enter a number: 4 Enter a number: 5 Enter a number: bad data Invalid input Enter a number: 7 Enter a number: done 16 3...
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. 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...
1. Write a function to keep asking the user for names in the form of strings, sort alphabetically and store these names into a text file named names.txt 2. Write a function that accepts a string as the argument, removes all alphabetical letters from the string, and returns it 3. Write a function that accepts a file name in the form of a string as the argument. Assume the text file contains single-digit numbers and letters. Read the entire contents...
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...
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 num...
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: must use loops and numbers to do this 1. Output the sum of all even numbers 2. Output the sum of all odd numbers 3. Output the count of all even numbers 4. Output the count of all odd numbers