0% found this document useful (0 votes)
31 views9 pages

C-49 - Karishma Mahajan - Python - EXP NO - 2

The document is an experiment report that aims to implement control statements like if/else, while, and for loops in Python. It includes sample code for if/else statements to check maximum of input values, while loops to print numbers in sequences, and for loops to print patterns. The output of the code is included. The conclusion states that the student learned to implement various control statements in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views9 pages

C-49 - Karishma Mahajan - Python - EXP NO - 2

The document is an experiment report that aims to implement control statements like if/else, while, and for loops in Python. It includes sample code for if/else statements to check maximum of input values, while loops to print numbers in sequences, and for loops to print patterns. The output of the code is included. The conclusion states that the student learned to implement various control statements in Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Name: Karishma Dhanesh Mahajan

Class: SE C Roll. No. 49

Experiment No.: 2 Batch:C3

AIM: To implement Control Statement like if


else, While, for loop

PROGRAM CODE:
#IF-Else
print("Enter a & b")
a=float(input())
b=float(input())
if a>b:
print(a,"is maximum")
else:
print(b,"is maximum")

print("Enter a, b and c\n")


a=int(input())
b=int(input())
c=int(input())
if a>b and a>c :
print(a,"is maximum")
elif b>a and b>c:
print(b,"is maximum")
elif c>a and c>b:
print(c,"is maximum")
else:
print("All are Equal")

1
percentage = float(input("enter percentage: "))
if 60 <= percentage :
print("first class")
elif 50 <= percentage:
print("second class")
elif 40 <= percentage:
print("Pass")
elif percentage < 40:
print("Fail")
else:
print("input valid percentage")

#While
i=1
while i<=10:
print(i)
i+=1

i=2
while i<=10:
print(i)
i+=2

i=1
while i<=10:
print(i*5)
i+=1

i=1
while i<=2:
print(i)
i+=0.1

i=5
while(i>=0) :
2
print(i)
i-=1

#For loop
for i in range(1,6):
print(i)

for i in range(5,0,-1):
print(i)

for i in range(1,6,1):
if i==3:
print("in")
continue
print("out")
print(i)

for i in range(1,11,1):
print(i*10)

for i in range(1,6):
print("X"*i)

for i in range(5,0,-1):
print("X"*i)

word=input("Enter word:")
for i in range(1, len(word)+1):
print(" " * (i - 1), word)

word = input("Enter word: ")


rWord = word[:: -1]
if word == rWord:
print("palindrome")
else:
print("not a palinedrome")
3
PROGRAM OUTPUT:

4
5
6
7
CONCLUSION:
We Learned To implement Control Statement like if
else, While, for loop

8
9

You might also like