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 script for the ice cream ordering system

ICT702 : Write a Python script for the ice cream ordering system.Your program must store the prices of the individual items (cones, scoop flavours and toppings)

  Write a program that generates two integers

Write a program that generates two integers under 100, show them on screen, and prompts the user to enter the sum of these two integers. The program then reports true if the answer is correct, false otherwise.

  Modify your code to ask the user for the id of a restaurant

Copy check1.py to check2.py and continue to work on check2.py. Modify your code to ask the user for the id of a restaurant between 1 and 155 (humans don't need to know about list ids starting at 0).

  Write a program that asks the user to enter their name

Write a program that asks the user to enter their name (First and last name), and the number of books that he or she has purchased this month and displays

  Define function which takes a decimal number as an input

HOLMES INSTITUTE - HS1031 Introduction to Programming Assignment - Define a function conversion.py which takes a decimal number as an input

  Examine the month entered by the user

Examine the month entered by the user. If it is larger than 12 or smaller than 1 issue an error message and ask for input again.

  The integers should be printed in order with addresses

The integers should be printed in order with addresses from main. When the steps of the function order have been completed the smallest value will be stored in a, the middle in b, and the largest in c.

  Write a function that takes as input an image object

Write a function that takes as input an image object, crops it to make it a square, and returns the resulting object. You must write a function to accomplish this.

  Write a program that uses a bar

Write a program that uses a bar chart to display the percent-ages of the overall grade represented by the project, quizzes the midterm exam and the final exam

  Write a python function which takes as argument python list

Write a Python function, which takes as argument a Python list of characters in upper- and lower-cases, char_list, to determine the frequency of each unique.

  Make program that used to store the booking information

The client want you to make a program that can be used to store the booking information, and the check-in information of the People on a flight

  Establish a socket to a dns server

A simple network application socket connection communication programming lab. Query the DNS server for a DNS host name or IP address.

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