TP n1 Python
TP n1 Python
20/3 6.666666666666667
20//3 6
20%3 2
5.45*10 54.5
2**4 16
2. Data Types
a = 10 it is an integer
<class 'int'>
print(type(a))
Exercises :
1. Write a script that asks the user for the day, month, and year, then displays the date as
follows:
Today’s Date is : 12/12/2023.
2. Describe what happens in each of the three lines of the example below:
>>> width = 20
>>>height = 5 * 9.3
>>>width * height
930.0
3. Assign the respective values 3, 5, and 7 to three variables a, b, c.
Perform the operation a - b // c.
Interpret the obtained result.
4. Change your script by asking the user to enter the three variables’ values, and then
display their types and the operation result.
5. Write a Python program that takes a student's score as input and outputs the
corresponding grade based on the following grading scale:
Score ≥ 90: Grade A
Score 80-89: Grade B
Score 70-79: Grade C
Score 60-69: Grade D
Score < 60: Grade F
Ensure that the input is valid (i.e., the score should be between 0 and 100).
If the input is invalid, print an error message like "Invalid score!"
6. Weather Decision System: Write a Python program that asks the user to input the
current weather conditions and decides whether a person should go for a walk based on
the following:
Instructions:
Example Output: