You are on page 1of 2

1.

Write a program to find out sum of squares of first n natural numbers

num= int(input(“Enter any natural number”))


while(num > 0):
sum += num
num -= 1
print("The sum is",sum)

2. Write a program to accept name, age, mobile no., state of the user and find out
whether he/she is eligible for voting or not.

name= input(“Enter your name”)


age= int (input(“Enter your Age”))
mobile=int (input(“Enter your mobile number”))
state=input(“Enter the state you belong from”)
if age>18:
status=”Eligible”
else:
status=”Not Eligible”
print(“You are”, status ,”for voting”)

3. Write a program to accept numbers and find out how many numbers are even or
odd.

x= int(input(“Enter a numer “))


if (num%2)==0:
print(“The number is even”)
else:
print(“The number is odd”)

4. Write a program to accept marks of n number of students for their 3 respective


subjects. Calculate average and sum of individual students as well as collectively

5. Write a program to find area of triangle

import math
a= int(input(“Enter first side”)
b= int(input(“Enter second side”)
c= int(input(“Enter third side”)
s=(a+b+c)/2
area=math.sqrt(s*(s-a)*(s-b)*(s-c))
print(“Area of the triangle is”,area)

6. Write a program to find Fibonacci series

num= int(input(“Enter the number”)


i=0
x=0
y=1
while (i<num):
if(i<=1)
z=i
else:
z=x+y
x=y
y=z
print (z)
i=i+1

7. Write a program to find factorial of a number

num=int(input(“Enter number to find factorial”)


x=1
i=1
while(i<=num):
x=x*i
i=i+1
print(“the factorial of”, num , ”is”, x)

8. Write a program to allow user to enter 10 numbers and find out their product and
sum
9. Modify code to allow 10 numbers and find their factorial
10. Allow user to enter no. till user enters -1
11. Write a function which will find out the sum of two digit number for a parameter
passed to it
12. Write a function which will find out sum of even nos. up to the term passed to it
13. Try out a function example given in slide 13 with appropriate understanding
14. Demonstrate an example with function by show casing use of default parameter
15. Write a function which will accept the input as age of the person and state of the
person and will return whether he/she is eligible for voting on their respective dates
of voting

You might also like