Starting from:
$30

$24

Homework #1 Solution

   Exercise 1 - Sequence of numbers

Your program will print out a sequence of numbers.
Write a program (in the file exercise1.py) that does the following:

1. asks the user to input a stricly positive integer which will be the first number in the
sequence
2. then, prints all the numbers in the sequence (1 line per number)
3. and finally, prints the sum of all the numbers in the sequence

   Exercise 2 - Software retails

Write a program (in the file exercise2.py) that does the following:

1. asks the user to input the number of packages he wants to buy
2. then, prints the total amount of the purchase after discount

NOTE: the total amount should keep two decimal places

   Exercise 3 - Leap Year and Soccer

Write a program (in the file exercise3.py) that does the following (in the specified order):

1. asks the user to input a year
2. prints the message Leap year or Not leap year on a first line
3. then, if applicable, prints the message World Cup year or Euro Cup year on a second
line

   Exercise 4 - Parking Fee

There is a parking lot near a restaurant. The parking ticket can record the day and time that
ticket has been issued and use it as Vehicle Enter Time. At the exit, exit date and time would
be recorded as Vehicle Exit Time.

Total parking time (in seconds) will be used to determine the parking fee.

Parking time = Vehicle Exit Time − Vehicle Enter Time

Write a program (in the file exercise4.py) that does the following (in the specified order):

1. asks the user to input Vehicle Enter Time (in the format of YYYY-MM-DD HH:MM:SS )
2. asks the user to input Vehicle Exit Time (in the same format)
3. prints the total parking time in hours and minutes, less than a minute will round up
to 1 minute
4. prints the parking fee
5. prints a message Warning: Overnight Parking when overnight parking applies

Syntax is very important, you have to print exactly with the same format as in the sample
examples on next page.

You should also notice that user input is always made of 19 characters.

The sample Python file already contains some statements to determine the Parking time in
seconds from 2 strings with the indicated format.

More products