The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Can you do the other problems for me? I have L9Q1 and L10Q1 now. Just let me know.
_______________________________________________________________________
Â
CIS115         Introduction to Programming and Logic                    Â
_______________________________________________________________________
Â
Â
LAB 09Â Â Â Â Â Â FUNCTIONS [PART 2]
Â
In this lab assignment, students will learn:
- How to write functions that multiple parameters
- How to write code to pass multiple arguments to a called function
- How to write code to generate random numbers
- How to use math functions
Â
In this lab assignment, students will demonstrate the abilities to:
- Write functions that multiple parameters
- Write code to pass multiple arguments to a called function
- Write code to generate random numbers
Â
Write a Python program for each of the problems in this lab. The following is an example.
Â
Lunch combos in the cafeteria of a community college include an entrée and a beverage. Write a program for customers to enter their choices. Define and use the following two functions:
Â
    chooseEntree : handle choice of entrée
    chooseBeverage: handle choice of beverage
Â
Also write and use a main function to implement the mainline logic of the program.
Â
Python program:
Â
__author__ = 'Man-Chi Leung'
defmain():
chooseEntree()
print()
chooseBeverage()
defchooseEntree():
print('Entree:')
print('Enter 1 for fish and chips')
print('Enter 2 for burger and fries')
print('Enter 3 for fried chicken and smashed potato')
print('Enter 4 for barbecue pork')
   entree = int(input('Please enter your choice: '))
if entree == 1:
print('You have chosen fish and chips')
elifentree == 2:
print('You have chosen burger and fries')
elifentree == 3:
print('You have chosen fried chicken and smashed potato')
elifentree == 4:
print('You have chosen barbecue pork')
defchooseBeverage():
print('Beverage:')
print('Enter 1 for iced tea')
print('Enter 2 for soda')
print('Enter 3 for coffee')
   beverage = int(input('Please enter your choice: '))
if beverage == 1:
print('You have chosen iced tea')
elifbeverage == 2:
print('You have chosen soda')
elifbeverage == 3:
print('You have chosen coffee')
main()
Â
Please use PyCharm to type and test your programs. Submit the Python files to Blackboard for credit. In this lab, you should submit 4 Python files, one for each problem.
Â
Â
Â
Write a program to convert US dollar to Japanese yen. This program has two functions: main and convert_to_yen. Please do the following:
Â
(a)Â Â In the main function, ask the user to enter amount in US dollar and conversion rate.
(b)  In the main function, call the convert_to_yen function. Pass the amount in US dollar and conversion rate as arguments.
(c)Â Â In the convert_to_yen function, write code to convert US dollar to Japanese yen and display the amount in Japanese yen.
Â
The following is an example.
Â
Enter amount in US dollar: 100
Enter conversion rate: 124.21
Equivalent amount in Japanese Yen: 12421.0
Â
Save your Python program in a file named Lab09P1.py. Submit the file to Blackboard for credit.
Â
Â
Write a program to calculate target heart rate during fitness training. This program has two functions: main and heart_rate_calculator. Please do the following:
Â
(a)Â Â In the main function, ask the user to enter age and resting heart rate.
(b)  In the main function, call the heart_rate_calculator function. Pass the ageand resting heart rate as arguments.
(c)Â Â In the heart_rate_calculator function, write code to calculate target heart rate during fitness training with the following formula:
Â
Target hart rate = (220 - age - resting heart rate) * 0.4 + resting heart rate
Â
         Display target heart rate.
Â
The following is an example.
Â
Enter age: 40
Enter resting heart rate: 70
Your target heart rate is 114.0
Â
Save your Python program in a file named Lab09P2.py. Submit the file to Blackboard for credit.
Â
Â
Write a program to play the rock-paper-scissors game. A single player is playing against the computer. In the main function, ask the user to choose rock, paper or scissors. Then randomly pick a choice for the computer. Pass the choices of the player and the computer to a find_winner function, which determines and displays the outcome of the game.
Â
The following are three examples.
Â
Enter 1 for rock, 2 for paper or 3 for scissors: 1
You chose rock. The computer chose scissors. You won.
Â
Enter 1 for rock, 2 for paper or 3 for scissors: 3
You chose scissors. The computer chose rock. The computer won.
Â
Enter 1 for rock, 2 for paper or 3 for scissors: 1
Both you and the computer chose rock. Tie.
Â
Save your Python program in a file named Lab09P3.py. Submit the file to Blackboard for credit.
Â
Â
      Write a program to do the following. Generate a random floating number between 12.5 and 17.5. Calculate the square root of the random number. Display both the random number and its square root.
.
The following is an example.
Â
The square root of 17.325617070542933 is 4.162405202589356
Â
Save your Python program in a file named Lab09P4.py. Submit the file to Blackboard for credit.
Â
Â
Writing and using main function [10 points]
Writing and using other functions [15 points]
Â
Generating random floating number [12.5 points]
Calculating square root [12.5 points]
Â
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly