## 09 Sep Monday 20:00 Python Practice 20.09.07.

**Question 1：(please use function that return a value)**

Write a program to display information to a driver based on his/her speed according to the following table:

km/h over the limit |
Fine |

1 to 20 | $100 |

21 to 30 | $270 |

31 or above | $500 |

Sample Input 1:Enter the speed limit: 40 Enter the recorded speed of the car: 39Sample output 1:Congratulations, you are within the speed limit!

Sample Input 2:Enter the speed limit: 100 Enter the recorded speed of the car: 131Sample output 2:You are speeding and your fine is $500

**Question 2：(please use function that return a value)**

You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages could be 5, 10 and 15, since both adjacent pairs have a difference of 5 years.

Given the ages of the youngest and middle children, what is the age of the oldest child?

The input consists of two integers, each on a separate line. The first line is the age Y of the youngest child. The second line is the age M of the middle child . The output will be the age of the oldest child.

Sample Input 1:Age Y: 12 Age M: 15Sample output 1:Age O: 18

Sample Input 2:Age Y: 10 AgeM: 10Sample output 2:Age O: 10

## Jesse Shi

Posted at 20:18h, 12 Septembersl = int(input(‘speed limit: ‘))

rs = int(input(‘recorded speed: ‘))

sl – rs = otl

if otl <= 20:

fine = 100

if otl = 30:

fine = 500

if sl >= rs:

print(‘good boy’)

if sl <= rs:

print('you can not get away with it')

the otl is not defined

## Ethan Li

Posted at 00:07h, 15 Septemberspeedlimit=input(‘Please enter the speed limit.’)

speed=input(‘Please enter your speed.’)

if speed speedlimit:

if speed>speedlimit 1-20:

fine=100

elif speed>speedlimit 21-30:

fine=270

else speed>speedlimit >30:

fine=500

print(‘You are speeding and your fine is: ‘, fine)