Calculate the total of the random integers and return

Assignment Help Python Programming
Reference no: EM132382478

Question

program5_1.py

Uses a custom function to generate a specified number of random integers in a specified range. This custom function should take three arguments; the number of integers to generate, the lower limit for the range, and the upper limit for the range. Values for these arguments should be entered by the user in main.

The custom function should display the random integers on one line separated by single spaces. The function should also report how many numbers were even and how many were odd. Finally, the function should calculate the total of the random integers and return this total back to main where it will be printed. User inputs in main are shown in blue.

Sample Output

How many integers are to be generated 8

Enter the lowest integer desired 10

Enter the highest integer desired 20

16 14 19 20 12 15 18 18

6 evens and 2 odds were generated

The total of those 8 random numbers is 132

program5_2.py

Determines the cost of painting the walls of a windowless room. There is one door and it will be painted the same color as the walls. The problem requires a main function and two custom functions that are imported from a custom module that you create. In main, the program should prompt the user for five inputs shown in blue in the Sample Output below:

the length, width, and height of the room in feet.
the cost of one quart of the chosen paint.
the square feet that can be covered by one quart of paint.

The three dimensions of the room should then be used as arguments for a function that calculates and returns the area of the walls in square feet.

This area and the remaining two inputs should be used as arguments for a second, void function that determines and prints the cost of the painting job. There will likely be paint left over. There is a method in the math module that you can use to "round up" the number of quarts needed.

Sample Output

Enter the length of the room in feet 20

Enter the width of the room in feet 16

Enter the height of the walls in feet 9

Enter the price of one pail of paint 24.99

Enter the sq ft covered by one pail 100

This job requires 7 pails of paint

The cost of paint is $174.93

program5_3.py

A (very) rudimentary shooter "game". You are the only shooter and you start with ammo of 10. The one enemy doesn't shoot back and starts with health of 5.

Code a custom function named shoot that prints "Shot fired" and returns True for a hit or False for a miss. Generate a random 0 to assign False or 1 to assign True. In the main function, use a while loop that runs the shoot function until you run out of ammo, at which point you lose. Report both hits and misses (see Sample Outputs).

If your shot is a hit as determined by the value returned by shoot, your code should lower the enemy's health. If you are lucky, the health of the enemy will be reduced to zero before you run out of ammo. If this happens, report the enemy's demise and use the break keyword to stop the loop. You have won.

Sample Output 1

Shot fired. Enemy was hit!

Shot fired. Shot missed

Shot fired. Enemy was hit!

Shot fired. Enemy was hit!

Shot fired. Enemy was hit!

Shot fired. Enemy was hit!

Enemy destroyed. You won!

GAME OVER

Sample Output 2

Shot fired. Shot missed

Shot fired. Enemy was hit!

Shot fired. Shot missed

Shot fired. Shot missed

Shot fired. Shot missed

Shot fired. Enemy was hit!

Shot fired. Shot missed

Shot fired. Shot missed

Shot fired. Shot missed

Shot fired. Enemy was hit!

You are out of ammo! You lose!

GAME OVER

Reference no: EM132382478

Questions Cloud

HSA 5923 Health Services Administration Capstone Project : HSA 5923 Health Services Administration Capstone Project Assignment, Homework Help, Florida National University, USA - Capstone Description of the Project
How to find the subset of n elements using a stack s : How to find the subset of n elements using a Stack S and a Queue Q using Python? The response paper should be in APA format.
Create a list then using a loop populate the list : Create a list then, using a loop, populate the list with N elements. Set each list element to the index multiplied by 10.
Calculate the sum of each value of n squared : Calculate the sum of each value of N squared from 0 up to and including N. The response paper should be in APA format, double spaced, hand-written.
Calculate the total of the random integers and return : Uses a custom function to generate a specified number of random integers in a specified range. This custom function should take three arguments;
How many us dollars are needed to purchase 3052 swiss : The exchange rate is 0.9706 Swiss francs per U.S. dollar. How many U.S. dollars are needed to purchase 3,052 Swiss francs?
Netherlands is planning to visit you in the united states : You estimate the cost of her trip at $2,531. What is the cost to her in euros if 1 Euro = $1.1559?
Write a class named jar whose instances represent glass jars : For this problem you are to write a class named Jar whose instances represent glass jars like you find in a kitchen. Here's how Jars behave.
Switzerland over summer and brought back : How many U.S. dollars will you get if you exchange your swiss francs for U.S. dollars? The exchange rate is 1 U.S dollar = 1.0638 swiss francs.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  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.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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