Lab2 PythonFirstSteps
Lab2 PythonFirstSteps
20/3
20//3
20%3
5.45*10
2**4
(3+2)*5
3+2*5
result = 3 + 5 * 2 ** 3 - 4 / 2
print(result)
result = (10 + 5) * 3 - 8 / 2 ** 2 + 1
print(result)
2. Data Types
type(1.5)
type(3.0)
type("bonjour")
type("3")
type(3+1.5)
a = 10
print(type(a))
b = 3.14
print(type(b))
c = True
print(type(c))
d = "Python"
print(type(d))
a = input("Enter your
height: ")
print(type(a))
a = float(input("Enter
your height: "))
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: