SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 305 Weeks Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 08 Jan 2018 My Price 10.00

code to pass multiple arguments to a called function

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]

    Objectives

     

    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

    Goals

     

    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

    - Use math functions

    Instruction and Problems

     

    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.

     


     

    Problem 1

     

    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.

     

    Problem2

     

    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.

     

    Problem3

     

    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.

     

    Problem4

     

           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.


     

    Grading rubric for Problems 1 through 3

     

    Writing and using main function [10 points]

    Writing and using other functions [15 points]

    Grading rubric for Problem 4

     

    Generating random floating number [12.5 points]

    Calculating square root [12.5 points]

     

Attachments:

Answers

(5)
Status NEW Posted 08 Jan 2018 01:01 PM My Price 10.00

-----------  ----------- 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

Not Rated(0)