Write a program that asks a user for a positive nonzero

Assignment Help Python Programming
Reference no: EM132083376

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.

Reference no: EM132083376

Questions Cloud

Credit sales are paid for in the current month : On average, 60% of credit sales are paid for in the current month, 20% in the next month, and the remainder in the month after that.
Identify improvements and propose the system to-be : New System development requires first to understand the system AS-IS, identify improvements, and propose the system TO-BE.
What is the weighted average cost of capital : The cost of equity is 14.5 percent and the aftertax cost of debt is 4.8 percent. What is the weighted average cost of capital?
Calculate the required external financing : What is the formula to calculate the required external financing over the next year?
Write a program that asks a user for a positive nonzero : 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.
What price would these bonds sell in the marketplace : At what price would these bonds sell in the marketplace? How many bonds would the firm have to issue to raise $1 million?
What is network segmenting : What is network segmenting? List four different types of network segments and provide examples for each from your daily life.
Weight of equity-weight of debt-cost of equity : What are the weight of equity, weight of debt, cost of equity, after tax cost of debt, Wacc.
Describe a design methodology of four stages to facilitate : Write your answer in the form of a management plan for this project. For each stage, indicate the number of weeks that should be allocated.

Reviews

Write a Review

Python Programming Questions & Answers

  Problem on the interactive execution

Interactive Execution. Start the Python interactive interpreter. You can invoke it by typing in its full pathname or just its name (python or python.exe).

  Write a program that asks the user for a letter

Write a program that asks the user for a letter. The program should then determine if the letter is a vowel or not

  Program that creates a dictionary containing

Write a program that creates a dictionary containing the U.S. states as keys and their capitals as values. The program should then randomly quiz the user by displaying

  Look up terms in a tech dictionary

Create a program that allows a user to look up terms in a tech dictionary - programming or scripting that is of interest to you, and complete one or more web-based tutorials on the topic.

  Write a program in python to draw a simplified face

Write a program in Python to draw a blue triangle in a drawing window. Write a program in Python that moves the triangle in an animated movement. Write a program in Python to draw a simplified face.

  What good are movie ids and ratings

Implement a function called topRated(). The function will take a file name as a parameter and return a sorted list - What good are movie IDs and ratings? You want to know the actual title of the movie! Implement a function called getTitles(). The fu..

  Write single file python program in jupyter notebook format

BUAN 6340 - Programming for Data Science Programming Lab. You will write a single file Python program in Jupyter Notebook format

  Make a python program that uses the getcwd

Make a Python program that uses the getcwd() function to provide a string of the current working directory. Save the string in the variable current folder and display the value.

  Write all the appropriate methods for the class

Create a Person class that contains the username, password, list of status updates, and list of friends. Write all the appropriate methods

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Write a program to that displays a table

Write a program to that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit and Kelvin equivalents

  Write program that is capable of generating a set words

You will write a Python program that is capable of generating a likely set of completion words given the start of a word as input to the program.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd