age = 25
name = "Mohamed"
is_student = False
if age < 18:
print("Hello Mohamed, you are a minor.")
else:
print("Hello Mohamed, you are an adult.")
if is_student is True:
print("You are eligible for a student discount")
else:
print("You are not eligible for a student discount")
PS C:\Users\HP\OneDrive\Desktop\MY PROJECTS\PYTHON> python [Link]
Hello Mohamed, you are an adult.
You are not eligible for a student discount
PS C:\Users\HP\OneDrive\Desktop\MY PROJECTS\PYTHON>
21/11/2024 Kodarit 2 task
Python Task: Variables and If Conditions
Task Description
Create a Python program that performs the following:
Variable Declaration:
Declare three variables: age, name, and is_student.
Assign appropriate values to these variables. For example, age could be an
integer, name a string, and is_student a boolean.
Conditional Statements:
Write an if-else statement that checks the value of age.
If age is less than 18, print a message saying, "Hello [name], you are a
minor."
If age is 18 or older, print a message saying, "Hello [name], you are an
adult."
Add another condition to check if is_student is True.
If is_student is True, print "You are eligible for a student discount."
If is_student is False, print "You are not eligible for a student discount."
Example Output
If age is 17, name is "Alex", and is_student is True, the output should be:
Hello Alex, you are a minor.
You are eligible for a student discount