0% found this document useful (0 votes)
5 views172 pages

Grade 10 Python Programming

The document contains various Python code snippets demonstrating basic programming concepts such as variables, data types, input/output, loops, and conditional statements. It includes examples for calculating volumes of geometric shapes, checking for even/odd numbers, and determining if a character is a vowel. Additionally, it covers tasks involving loops for counting and summing numbers based on user input.

Uploaded by

brooklycuts2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views172 pages

Grade 10 Python Programming

The document contains various Python code snippets demonstrating basic programming concepts such as variables, data types, input/output, loops, and conditional statements. It includes examples for calculating volumes of geometric shapes, checking for even/odd numbers, and determining if a character is a vowel. Additionally, it covers tasks involving loops for counting and summing numbers based on user input.

Uploaded by

brooklycuts2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

# print value stored in a variable

"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''
'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")
#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''
#PRECONDITION LOOP -CONDTION MUST BE TRUE
BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers
# Step 4: Add = and total at the end of the expression
expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''
# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""
#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)
#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""
for i in range(number, 0, -1): # from number down to 1
total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)
print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''
#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3
#countdown using while loop from 10 to 0
'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''
#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''
#input can also be in the form of file .txt .excel
#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)
cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''
#cout controlled loop(for loop-number of loops is known or
predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2
#POST CONDITION LOOP - CONDITION IS CHECKED
AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""
#Constants and variables
'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")
'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)
rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''
1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""
#Constants and variables
'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))
volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N
#USER INPUT NUMBERS REPEADEDLY UNTIL THE
USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''
#expression building and printing
number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)
'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-
for value in range(4,24,4):
print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)
# print value stored in a variable
"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''
#input and output
'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''
#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed
Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)
# print value stored in a variable
"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''
#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed
Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or
number=int(input("enter the number:"))
while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)
# print value stored in a variable
"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''

#PRECONDITION LOOP -CONDTION MUST BE TRUE


BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''
'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")
#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers

# Step 4: Add = and total at the end of the expression


expression += " = " + str(total)
print(expression)

# print value stored in a variable


"""
👇
x=5
x=5+5
x=15-1
print(x)
print(x+5)
"""

#Constants and variables


'''
total_price_var=0
ticket_price_const=10
number_of_tickets=int(input("Enter the number of
tickets:"))
total_price_var=number_of_tickets * ticket_price_const
print(total_price_var)
'''

# datatypes in py
'''
number=10
real=10.2
char='a'
string="Hello"
boolean=True
print(number,real,char,string,boolean)
'''

#input and output


'''
name=input("Enter your name:")
age=int(input("Enter your age:"))
print("Hello",name,"you are",age,"years old")
if age>18:
print("You are eligible to vote")
else:
print("You are not eligible to vote")

'''

#input can also be in the form of file .txt .excel


#the default input is string
"""
height=float(input("Enter your height in meters:"))
print("Your height is",height)
"""

#QUESTION 1
#calculate the volume of a sphere
'''
radius=float(input("Enter the radius of the circle:"))
sphere_volume=(4/3)*3.14*radius**3 #radius to the power
of 3
print("sphere volume is",sphere_volume)
'''

#Question 2
#calculate the volume of a cylinder
'''
import math
Radius=float(input("enter the radius of the circle:"))
Height=float(input("enter the height of the cylinder:"))

volume_cylinder=3.14*Radius**2*Height
print ("volume of the cylinder is",volume_cylinder)

rounded_cylinder=round(volume_cylinder,2)
print(rounded_cylinder)

cieled_cylinder=[Link](volume_cylinder)
floored_cylinder=[Link](volume_cylinder)

print(cieled_cylinder)
print(floored_cylinder)
'''
#question 4
''''
#GRADES
Grade = (input("enter the grade:"))
if Grade=="A":
print("Excellent")
elif Grade=="B":
print("Good")
elif Grade=="C":
print("Average")
elif Grade=="D":
print("Below Average")
elif Grade=="F":
print("Fail")
print("Better luck next time")
'''
'''
#Question 5
#Even or odd
Number=int(input("Enter the number:"))
if Number%2==0:
print("Even")
else:
print("Odd")
'''

#question 6
#To find wheather the character is vowel or not
'''
character=input("enter the character:")
if character=='a':
print(character,'is vowel')
elif character=='e':
print(character,'is vowel')
elif character=='i':
print(character,'is vowel')
elif character=='o':
print(character,'is vowel')
elif character=='u':
print(character,"is vowel")
elif character=='b' or character=='c' or character=='d' or
character=='e' or character=='f' or character=='g' or
character=='h' or character=='i' or character=='j' or
character=='k' or character=='l' or character=='m' or
character=='n' or character=='o' or character=='p' or
character=='q' or character=='r' or character=='s' or
character=='t' or character=='u' or character=='v' or
character=='w' or character=='x' or character=='y'or
character=='z':
print(character,"is consonant")
'''

#cout controlled loop(for loop-number of loops is known or


predecided))pyhton does't print the last number)
#counter varaible is incremented by 1 by default
'''
for counter in range(1,10):
print(counter)

#to increment by 2
for counter in range(1,20,2):
print(counter)
'''
#PRECONDITION LOOP -CONDTION MUST BE TRUE
BEFORE THE LOOP STARTS
#(while loop-number of loops is not known or predecided)
'''
Total=0
print("Enter the numbers to be added until -1 to finish:")
Mark=int(input("Enter the number:"))
while Mark!=-1: #condtion must be met before the
indented code is executed
Total=Total+Mark
Mark=int(input("Enter the number:"))
print("Total is",Total)
'''

1#DAY -2

#POST CONDITION LOOP - CONDITION IS CHECKED


AFTER THE LOOP IS EXECUTED REPEAT UNTIL LOOP
IN PSUEDOCODE ,python does not have repeat until loop
but we can use while loop to achieve the same result
'''
Total=0
Mark=0
while True:
Mark=int(input("Enter the number:"))
if Mark==-1:
break
Total=Total+Mark
print(type(Total))
'''
'''
#TASK 1
#-USE A FOR LOOP TO OUTPUT THE FIRST 5
MULTIPLES OF 3-

for value in range(4,24,4):


print(value)

'''
#TASK 2
#USE FOR LOOP TO OUTPUT FROM 10 TO 0
'''
Countdown_Timer=0
for Countdown_Timer in range(10,-1,-1):
print(Countdown_Timer)
'''

#Task 3

#countdown using while loop from 10 to 0


'''
Value=100
while(Value<=100):
print(Value)
Value=Value-1
if(Value==-1):
break
'''

'''
#why 10 is not printed in the below code and -1 is printed

Value=10
while(Value<=10):
Value=Value-1
print(Value)
if(Value==-1):
break
'''
#OR WE CAN USE to simply print from 10 to 0
'''
value=10
while value>=0:
print(value)
value=value-1
'''
#TASK 4 WRITE A PROGRAM TO INPUT NUMBERS
REPEATEDLY UNTIL THE USER ENTERS A POSITIVE
NUMBER
'''
number=int(input("enter the number:"))
while True:
if number<0:
number=int(input("enter the number:"))
else:
break
print("positive number entered")

#or

number=int(input("enter the number:"))


while number<0:
number=int(input("enter the number:"))
print("positive number entered")
'''
#TASK 5 SUM TO N

#USER INPUT NUMBERS REPEADEDLY UNTIL THE


USER KEYS IN POsITIVE NUMBER ,USING THE
POSITIVE NUMBER (N).
#CALCULATE THE SUM OF ALL THE NUMBERS
ENTERED BY THE USER
"""""
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")
sum=number*(number+1) /2
print(sum)
"""""
#OR
'''
number=int(input("enter the number:"))
while(number<0):
number=int(input("enter the number:"))
else:
print("positive number entered")

total=0
n=number
for i in range(1,n+1):
total=total+i
print("The total sum from 1 to", number, "is:", total)
'''

#expression building and printing


number = int(input("Enter the number: "))
# Step 1: Validate input
while number < 0:
number = int(input("Enter a positive number: "))
else:
print("Positive number entered")
# Step 2: Calculate total and build reverse expression like
5+4+3+2+1
total = 0
expression = ""

for i in range(number, 0, -1): # from number down to 1


total =total+ i# Add each number to the total
expression += str(i) # Add the number to the expression
string
if i != 1:
expression += " + "# Add plus sign between numbers
# Step 4: Add = and total at the end of the expression
expression += " = " + str(total)
print(expression)

You might also like