Python Practical Questions
Python Practical Questions
Python Practical Questions
Q1. Write a python program to find the largest of given three numbers using if
construct.
CODE:
CODING:
CODING:
Import math
s=0
For i in range(1,101):
sqr=math.pow(i,2)
s=s+sqr
print("The sum of squares of the first 100 natural numbers is: ",s)
Q4.To print the first ‘n’ multiples of given number.
CODING:
#Program to print the first 'n' multiples of given number. num=int(input("enter the
number"))
print('**************’)
for a in range(1,n+1):
res=num*a
print(res)
Q5.Write a program to create a dictionary to store names of states
and their capitals.
CODING:
#states={}
states[state]=capital
CODING:
students={}
n=int(input("How many students are there?"))
for i in range(n):
marks=[]
for j in range(5):
mark=float(input("ENTER THE MARKS- "))
marks.append(mark)
students[sname]=marks
s=input("Enter
string:") vowels=0
for i in s:
if i in ['a','e','i','o','u','A','E','I','O','U']:
vowels=vowels+1
print(vowels)