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

python record

Uploaded by

emimavjangel
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 views5 pages

python record

Uploaded by

emimavjangel
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
You are on page 1/ 5

23CS1008 Python Programming Lab

Ex.No.1
USE OF CONTROL STATEMENTS Reg. No :URK24CS1033
16.12.24

1a. Write a python program to find the factorial of a number using while loop.

Aim:
To write a python program to find the factorial of a number using while loop.

Description/Algorithm:

Step1: Start the program


Step2: Get input from user
Step3: Initialize f=1
Step4: Start while loop giving condition of n>1
Step5: Multiply f*n
Step6: Modify by n=n-1
Step7: Print result
Step8: Stop the program

Program:

n=int(input(“enter a number:”))
factorial=1
while n>0:
factorial *=n
n=n-1
print(“factorial of a number is:”, factorial)

Output: (Screenshots)

Result: Hence the output is verified.

1
23CS1008 Python Programming Lab

2
23CS1008 Python Programming Lab

1c. Write a python program to print alphabet pattern.

Aim:
The aim of the program is to write a python program to print alphabet pattern ‘E’.

Algorithm:

Step1: Start the program


Step2: Print first row *****
Step3: Print second row*
Step4: Print third row*
Step5: Print fourth row****
Step6: Print fifth row*
Step7: Print sixth row*
Step8: Print seventh row*****

Program:

print(“*****”)
print(“*”)
print(“*”)
print(“****”)
print(“*”)
print(“*”)
print(“*****’)

Output: (Screenshots)

Result: Hence the output is verified.


3
23CS1008 Python Programming Lab

1e. Write a python program to check whether the number is palindrome or not.

Aim:
The aim of the program is to check whether the number is palindrome or not .

Algorithm:

Step1: Start the program


Step2: Get the number from user
Step3: Convert number to string
Step4: Give condition to reverse a string [::1]
Step5: Compare original and reversed string
Step6: Check using if condition
Step7: End the program

Program:

number=input(“enter a number:”)
if number ==number[::-1]:
print(“The given number is palindrome”)
else:
print(“The given number is not palindrome”)

Output: (Screenshots)

Result: Hence the output is verified.

4
23CS1008 Python Programming Lab

You might also like