Python Practical
Python Practical
FUNDAMENTALS USING
PYTHON
PRACTICALS
NAME : MOHIT KUMAR
ROLL NO : 24HEL2129
SEMESTER : I
1) AIM : Write a python menu driven program to
calculate area of circle, rectangle, square using if-elif-
else.
Program :
#Menu Driven
while True :
print('''
----------Menu Driven-----------
1. Area of Rectangle
2. Area of Sqaure
3. Area of Circle
4. Exit
--------------------------------''')
if ch == 1 :
elif ch==2 :
elif ch==3 :
elif ch==4 :
break
else :
print("Wrong Choice")
Output :
2) AIM : Write a python program to print Fibonacci series
up to a certain limit (use ‘while’).
Program :
#Fibonacci Series
n = int(input("Number of Fibonacci Series to be Printed: "))
a, b = 0, 1
print(a, b, end=' ')
i=0
while (i < n-2):
c=a+b
# add the last two numbers and print
print(c, end=' ')
a=b
b=c
i=i+1
Output :
Output :
Output :
Output :
6) AIM : Write a python program to illustrate the various
functions of the “Math” module, “Statistics” module in
python.
Program :
import math
import statistics
Output :
7) AIM : Write a python program to count number of
vowels using sets in given string.
Program :
#Vowels in a string
s = input("Enter string to check : ")
vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}
c=0
for i in s :
if i in vowels :
c+=1
print("Total numeber of vowels in string :",c)
Output :
Output :
9) AIM : Write a python program to count positive and
negative numbers in a list.
Program :
#count negative positive
l = [1,6,3,7,-3,7,2,-4]
n,p = 0,0
for i in l :
if i>=0:
p+=1
else :
n+=1
print("Count of positive numbers in the list :",p)
print("Count of negative numbers in the list :",n)
Output :
Output :