( Look at the desktop mode to get the right view. )
1. Write a python program to find area of circle.
PI=3.14
radius=int(input("Enter radius of circle: "))
area=PI*radius*radius
print("Area of circle is : ",area)
2.write a python program to print this pattern.
*
**
***
****
for i in range(1,5):
print("*"*i)
3. Write a python program to change the value celsius to fahrenheit.
c=float(input("Enter value in celcius: "))
far=c*1.8+32
print("The value is farenheit is: ",far)
4. Write a python program to find the area of triangle.
base=float(input("Enter value of base: "))
height=float(input("Enter value of height: "))
area=1/2*base*height
print("Area of the triangle is: ",area)
5. Write a python program to check leap year or not.
year = int(input("Enter any year: "))
if (year%4==0 and year%100!=0) or year%400==0:
print("leap year")
else:
print("not a leap year")
6. Write a python program to check number is even or odd.
num=int(input("Enter any number: "))
if num%2==0:
print("given number is Even")
else:
print("odd number")
7. Write a python program to print all number from 0 to 6 numbers except 3 and 6.
for i in range(7):
if i==3 or i==6:
continue
print(i)
8. Write a python program swapping two number.
a=int(input("Enter value of a: "))
b=int(input("Enter value of b: "))
print("before swaping value of a =",a,"b=",b)
temp=a
a=b
b=temp
print("after swaping value of a =",a,"b=",b)
9. Write a python program to check number is positive , negative or zero.
num=int(input("Enter any number: "))
if num>0:
print("positive")
elif num<0:
print("negative")
else:
print("zero")
10. Write a python program to convert decimal to binary, octal and hexadecimal.
deci=int(input("Enter value in decimal: "))
print("binari value is ",bin(deci))
print("octal value is ",oct(deci))
print("hexadecimal value is ",hex(deci))
11. Write a python program to find gcd of two numbers.
a=int(input("enter 1st number: "))
b=int(input("enter 2nd number: "))
while b!=0:
a,b=b,a%b
print("The gcd is ",a)
12. Write a python program to find the lcm of two numbers.
a=int(input("Enter 1st number: "))
b=int(input("Enter 2nd number: "))
if a>b:
greater=a
else:
greater=b
while True:
if greater%a==0 and greater%b==0:
lcm=greater
break
greater+=1
print("The lcm of ",a,"and",b,"is",lcm)
13. Write a python program to find the sum of digits.
num=input("Enter any number: ")
sum=0
for digit in num:
sum=sum+int(digit)
print("The sum of digits ",sum)
14. Write a python program to find the sum of any five numbers.
sum=0
for i in range(5):
num=int(input("Enter any number: "))
sum=sum+num
print("The sum of all five number: ",sum)
15. Write a python program to find the sum of square root of any three numbers .
import math
sum=0
for i in range(3):
num=int(input("Enter any number: "))
sum=sum+math.sqrt(num)
print("The sum of square root of three number is : ",sum)
16. Write a python program to implement a calculator to do basic operations like (+,-,*,/).
num1=float(input("Enter 1st number: "))
op=input("Enter + or - or * or / : ")
num2=float(input("Enter 2nd number: "))
if op=="+":
print("addition is ",num1+num2)
elif op=="-":
print("subtraction is ",num1-num2)
elif op=="*":
print("multiply is ",num1*num2)
elif op=="/":
print("divide is ",num1/num2)
else:
print("invalid operator")
Please Like
Q.Write a python program to check vowels or not.
c=input("Enter any char: ")
vowels={'a', 'e', 'i', 'o' ,’A’ ,’E’ ,’I’ ,’O’ ,’U’}
if c in vowels:
print("vowel")
else:
print("not a vowel")
0 टिप्पणियाँ
If you have any doubt, please let me know
Emoji