Write a program that asks a user for a positive nonzero


All programs should be submitted in one file that end in .py . Put a comment at the start of each program.

a) Write a program that asks a user for a positive nonzero integer value. The program should use a "while loop" to get the sum from 1 up to the number entered. For example if the user entered 10, the answer printed out should be 55, because the sum 1,2,3,...10 is 55.

b) Write the same program as above using a "for loop".

C) The following program simulates flipping a coin one million times and displays the number of heads and tails

import random

headCount = 0

tailCount = 0

for count in range(1000000):

number = random.randint(0, 1)

if number == 0:

headCount += 1

else:

tailCount += 1

print("head count:", headCount)

print("tail count:", tailCount)

Use the above as a guide and write a program that simulates throwing a six sided die one million times and displays the number of times each side shows up.

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Write a program that asks a user for a positive nonzero
Reference No:- TGS02876835

Expected delivery within 24 Hours