Homework 2
The deadline is Sunday, the 20th of September, 23:59 (Estonian time).
Exercise 1. Admission to the University of Tartu
Write a program to solve the following problem.
The University of Tartu uses different coefficients to calculate the admission score for each curriculum. A student's application is considered for admission only if the admission score is 66 points or higher. Your task is to write a program that asks the user for the admission score. The program has to output whether the obtained score is enough to be considered for admission to the University of Tartu. Also the program has to check the validity of the entered score: the maximum points for all curricula are 100; a valid score cannot be negative.
Some examples of the program output are shown below:
Enter the number of points: 85 The obtained points are enough to be considered for admission
Enter a number of points: 65 The obtained points are not enough to be considered for admission
Enter a number of points: 115 You cannot obtain so many points
Enter a number of points: -1 You cannot obtain negative points
Exercise 2. Number of days in months
Write a program that asks the user to enter the number of a month. The program has to output the number of days in that month. Also make sure if the user inputs anything ridiculous, the program has to give a corresponding feedback about it. Use try-except.
Test your program with different inputs and make sure the program works correctly. For example: -100, 0, 1, 2, 5, 9, 10, 12, 13, 100, blabla
Here are some examples of the program output.
Enter the number of a month: blabla Please enter a number
Enter the number of a month: 0 The number of a month must be in the range [1-12]
Enter the number of a month: 12 That month has 31 days in it.
Enter the number of a month: 4 That month has 30 days in it.
Optional part
If you can (and it is not very difficult at all) also try to check against the leap year. In that case, the program has to ask the user about the year.
Here are some examples of the program output if the entered number is 2 (February):
Enter the number of a month: 2 Enter a year: 2015 That month has 28 days in it (a common year).
Enter the number of a month: 2 Enter a year: 2000 That month has 29 days in it (a leap year).
Enter the number of a month: 2 Enter a year: 2100 That month has 28 days in it (common year).
Enter the number of a month: 2 Enter a year: 2016 That month has 29 days in it (a leap year).
Go to Moodle and upload your solution into Homework 2.