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

  Implement algorithms for sorting in python

MCD4710 Algorithmic Problem Solving - write a Python program similar to the one from Part A but sort by the total medal count instead. So instead of sorting by the number of gold medals that each team won, this time it should be sorted by the total..

  Write the python code for the problems

Topic: CS and Math. Write the python code for the following problem. Implement the modified Cholesky's algorithm by integrating

  Write a recursive function that takes in a list

For this part of the homework, you will write a recursive function that takes in a list of positive integers as a parameter, and prints out the maximum value in that list. Your recursive function should be called maxInt().

  Describe the original data for the city you are observing

Describe the original data for the city you are observing. Regression Analysis Hypothesis testing. Explain the hypothesis and the result by graph.

  Write python script that reads and analyses country metadata

ICT702 Task 2 - Theme: Child Mortality. In this second part of Task 2, you should write another Python script that reads and analyses the country metadata

  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.

  Explain a python program storing and processing simple bank

A Python program storing and processing simple bank records is in the early stages of development. The records are stored in a text file (bank.txt) that contains, for each bank customer, their given name, account number and balance.

  Program that allows user to do basic trigonometry functions

You need to create a program that allows the user to do basic trigonometry functions. First, ask the user if he or she would like to do sine, cosine, or tangent.

  Design and implement mini-missions in the haunted house

Create a cheat commands in the game so player can pick up any item he wants from any location in the map. You have to name this cheat command 'giveme'

  Implement a function that takes a filename as input

FIT1008 - Implement a function that takes a filename as input and reads it into an instance of the class you implemented on Task 2. For each line in the file

  Write a python program that generates a small web site

Choose a sport or club, and get some suitable input data.. If you play a sport yourself, see if you can get some data files for your sport.

  Build a menu-driven application

Build a menu-driven application that will allow a user to maintain their collections. For example, I might have a coin collection, or a record collection, or a collection of all my valuable items.

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