Question

In: Computer Science

One Problem/Question (Four Parts) Write a python program which prints a sequence of integers that are...

One Problem/Question (Four Parts)

  1. Write a python program which prints a sequence of integers that are multiples of 10, starting at 0 and ending at 100.
  2. Write a python program that computes the average of 10 random odd integers, ranging from 0 to 500.
  3. Write a python program that prints whatever the user enters, and stops when the user types “done”, using an infinite loop and a break statement.
  4. Same as number three but use a condition. The loop terminates when the condition is equal to “done”.

1 Sample run:
0
10
20
30
40
50
60
70
80
90
100

2 Sample run:
449

9

143

101

115

479

299

115

199

211

The Average of the numbers is: 212.0

3 & 4 Sample run:
say something: hello
you said :   hello
say something: what's up?
you said :   what's up?
say something: done
you said :   done
Goodbye!

Solutions

Expert Solution

#1
num=0
while num<=100:
print(num)
num+=10


#2
import random
total=0
for i in range(10):
num=random.randint(0,500)
while num%2==0:
num=random.randint(0,500)
total+=num
print(num)
print('The Average of the numbers is:',total/10)


#3
while True:
say=input('say something: ')
print('You said:',say)
if say=='done':
break
print('Goodbye!')


#4
say=' '
while say!='done':
say=input('say something: ')
print('You said:',say)
print('Goodbye!')


Related Solutions

Text Wrap Problem Write a program in Python that takes an input string and prints it...
Text Wrap Problem Write a program in Python that takes an input string and prints it as multiple lines of text such that no line of text is greater than 13 characters and words are kept whole. For example, the first line of the Gettysburg address: Four score and seven years ago our fathers brought forth upon this continent a new nation, conceived in liberty and dedicated to the proposition that all men are created equal Becomes: Four score and...
In python write a program which prints the longest substring of numbers which occur in ascending...
In python write a program which prints the longest substring of numbers which occur in ascending order s=342153476757561235
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
Intro to Python! 1. Using while loops, write a program that prints multiples of 5 which...
Intro to Python! 1. Using while loops, write a program that prints multiples of 5 which are less than 100. Your loop initially starts from 0. 2. Consider B to be a list of alphabetically ordered strings. Using while loops, write a program that only prints words which start with letter A. B = [Alex, Airplane, Alpha, Australia, Ben, Book, Bank, Circuit, Count, Dark] 3. Using while loop, create a program that only prints first 18 multiples of 7.Hint: Your...
Write a program that initializes an array of 6 random integers and then prints 4 lines...
Write a program that initializes an array of 6 random integers and then prints 4 lines of output, containing the following: 1. Only the first and last element 2. Every element at an odd index 3. Every odd element 4. All elements in reverse order
Write a program that uses a while statement to read integers from the user and prints...
Write a program that uses a while statement to read integers from the user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters 999. The average should be output with 4 digits of precision. c++ please ASAP
PLEASE WRITE IN PYTHON A sequence of integers is said to be Fibonacci-like if each element...
PLEASE WRITE IN PYTHON A sequence of integers is said to be Fibonacci-like if each element of the sequence (except the first two elements) is the sum of the previous two integers in the sequence. For example, the sequence 10, 14, 24, 38, 62, 100, 162, 262 is Fibonacci-like. Note that the first two integers in the above sequence are arbitrary. Each of the remaining integers is the sum of the two integers just before it in the sequence. For...
python Write a program that prints your name 100 times to the screen. Write a function...
python Write a program that prints your name 100 times to the screen. Write a function that takes a string s and an integer n as parameters and prints the string s a total of n times (once per line). Write a for loop that prints all the integers from 3141 to 5926, skipping every other one. Write a for loop that prints every 5th integer from 5926 down to 3141. Write a program (using a for loop) to print...
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT