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

Use Python to solve, show all code Write a program that sums a sequence of integers...
Use Python to solve, show all code Write a program that sums a sequence of integers from a starting integer to and ending integer. The sequence is generated by skipping a value (e.g. 1,3,5,… or 2,6,10,14…). Prompt the user for a) a starting value greater than 0. Validate the value is greater than 0. b) the ending value. c) the value to skip Print out the sum of the numbers for the sequence. If the starting value is 2, the...
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 in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out...
Write a program in PYTHON which: *Defines the following 5 functions: whoamI() This function prints out your name and PRINTS OUT any programming course you have taken prior to this course. isEven(number) This function accepts one parameter, a number, and PRINTS OUT a message telling if the numberer is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two. printEven(number) This function accepts one parameter, a number,...
c program Write a program that asks the user to enter a sequence of 15 integers,...
c program Write a program that asks the user to enter a sequence of 15 integers, each either being 0, 1, or 2, and then prints the number of times the user has entered a "2" immediately following a "1". Arrays are not allowed to appear in your code. Include ONLY THE SCREENSHOT OF YOUR CODE in an image file and submit the file.
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT