Python代写|CP1401/CP5639 2022 TR1 Assignment 1

3个程序任务为:1.Pay Calculator:输入、处理和输出  2.Space Cadet Results:决策结构  3.Sleep Tracker:重复性结构

Requirements and Expectations:

Ensure that your programs match these, including spacing, spelling, etc. Think of this as helpful guidance as well as training you to pay attention to detail. The sample output is intended to show a full range of situations so you know how the programs should work.

That’s fine.

Program 1 – Pay Calculator:

Learning outcome focus: Input, Processing, Output

File name: a1_1_pay_calculator.py

At Experience Counts, workers get paid based on their level of experience.

Write a program that asks an employee for their number of hours worked and experience level, then displays how much their total pay will be.

There is no limit to an employee’s experience level and no error-checking is required.

The base pay for experience level 0 is $45.00

Each level of experience gives 5% more pay, so experience level 1 is $47.25; experience level 3 is 15% more than the base, or $51.75, etc. You should write your program so that if the base pay were to change, the programmer would only need to change it in one place (that’s what constants are for).

The sample output below shows the currency values displayed with two decimal places, which your program should also do.

Sample Output from 3 different runs:

It should be clear what parts of the samples are user input for all samples in this document.

E.g., in the first example below, the user entered 10 and 3. All of the other parts of the sample were

printed by the program.

Experience Counts Pay Calculator

Number of hours worked: 10

Experience level: 3

Based on your experience level (3):

Your hourly pay rate is $51.75

Your total pay is $517.50

Experience Counts Pay Calculator

Number of hours worked: 40

Experience level: 99

Based on your experience level (99):

Your hourly pay rate is $267.75

Your total pay is $10710.00

Experience Counts Pay Calculator

Number of hours worked: 0

Experience level: 52

Based on your experience level (52):

Your hourly pay rate is $162.00

Your total pay is $0.00

Program 2 – Space Cadet Results:

Learning outcome focus: Decision Structures

File name: a1_2_space_cadet.py

This program helps determine the fate of trainee space cadets.

Users can enter scores for their practical work and their exam (each expected between 0 and 50).

The system then determines their results as follows:

Trainees fail if their total score is under 50.

If trainees do not fail, then they either become:

– a field agent, if their practical score is greater than or equal to their exam score

– a desk officer, if their exam score is greater than their practical score

If a trainee’s total score is 90 or greater, they make the honour roll.

Note: there is no looping or error-checking in this program.

Sample Output from 3 different runs:

Welcome Trainee Space Cadet. How did you do?

Practical score (0-50): 24

Exam score (0-50): 25

Your total score is 49 out of 100.

You failed. Please try again next year.

Welcome Trainee Space Cadet. How did you do?

Practical score (0-50): 39

Exam score (0-50): 23

Your total score is 62 out of 100.

You will become a field agent.

Welcome Trainee Space Cadet. How did you do?

Practical score (0-50): 44

Exam score (0-50): 46

Your total score is 90 out of 100.

You will become a desk officer.

Congratulations on making the honour roll!

Program 3 – Sleep Tracker:

Learning outcome focus: Repetition Structures

File name: a1_sleep_tracker.py

A “sleep debt” represents the difference between a person’s desirable amount of sleep and how long they actually sleep for. Write a program that prompts the user to enter how many hours they slept each day over a work-week period of 5 days, then informs them of their sleep debt status.

Using 8 hours per day as the desirable amount of sleep, determine their sleep debt by calculating the total actual hours of sleep and subtracting that from the total desirable hours of sleep.

Display results messages as demonstrated below.

Note that in this program, you must use an error-checking loop to ensure that the user’s inputs are within the range 0-24 inclusive.

As with the other programs, you should think about using CONSTANTS to make it easy (in one place) to change the program, such as calculating sleep debt for a period of 7 days instead of 5.

With (next to) your pseudocode for this question, include a brief justification/explanation of which repetition pattern(s) you chose to use and why.

Sample Output from 2 different runs:

Sleep Tracker

Night 1 hours sleep: 7.5

Night 2 hours sleep: -3

Invalid number of hours.

Night 2 hours sleep: 25

Invalid number of hours.

Night 2 hours sleep: 0

Night 3 hours sleep: 8.75

Night 4 hours sleep: 6

Night 5 hours sleep: 7

Recommended total sleep is: 40

Your total hours of sleep : 29.25

Your sleep debt over this time is: 10.75

Sleep Tracker

Night 1 hours sleep: 8

Night 2 hours sleep: 8

Night 3 hours sleep: 8

Night 4 hours sleep: 8

Night 5 hours sleep: 8

Recommended total sleep is: 40

Your total hours of sleep : 40.0

You are getting enough sleep. Keep it up!