Basic Program of Python Part-I
Basic Program of Python Part-I
Sum of 5 + 10 = 15
Question 2:- Program to find area and circumference of circle.(area=Pi * r * r and Circumfrence=2 * pi * r)
Question 3:- Program to find Simple Interest. ( SI=(Principal Amount * Rate of Interst * time)/100)
SI=(p*r*t)/100
print(f"Simple Interst = {SI} .")
Enter the Principal Amount:- 10000
Enter the Rate of Interst:- 5
Enter the Time:- 2
Question 4:- Program to convert temperature from degree centigrade to Fahrenheit.(f=(1.8 * c ) + 32)
Question 7:-Program to show swap of two Number without using third variable.
10
20
30
40
50
60
70
80
90
100
1 X 1 =1 1 X 2 =2 1 X 3 =3 1 X 4 =4 1 X 5 =5
2 X 1 =2 2 X 2 =4 2 X 3 =6 2 X 4 =8 2 X 5 =10
3 X 1 =3 3 X 2 =6 3 X 3 =9 3 X 4 =12 3 X 5 =15
4 X 1 =4 4 X 2 =8 4 X 3 =12 4 X 4 =16 4 X 5 =20
5 X 1 =5 5 X 2 =10 5 X 3 =15 5 X 4 =20 5 X 5 =25
6 X 1 =6 6 X 2 =12 6 X 3 =18 6 X 4 =24 6 X 5 =30
7 X 1 =7 7 X 2 =14 7 X 3 =21 7 X 4 =28 7 X 5 =35
8 X 1 =8 8 X 2 =16 8 X 3 =24 8 X 4 =32 8 X 5 =40
9 X 1 =9 9 X 2 =18 9 X 3 =27 9 X 4 =36 9 X 5 =45
10 X 1 =10 10 X 2 =20 10 X 3 =30 10 X 4 =40 10 X 5 =50
6 is greatest.
Question 12:- Program to find that entered year is leap year or not.
num1=int(input("Enter Number:-"))
if num1%2==0:
print(f"Number {num1} is Even")
else:
print(f"Number {num1} is Odd")
Enter Number:- 5
Number 5 is Odd
num1=int(input("Enter Number:-"))
left_shift= num1<<2
right_shift=num1>>2
print(f"The result of Shifting {num1} by two bits to the left is {left_shift} ")
print(f"The result of Shifting {num1} by two bits to the right is {right_shift} ")
Enter Number:- 5
# Python doesn’t have a direct switch statement like some other languages
def display_days(day_number):
days = {
1: "Monday",
2: "Tuesday",
3: "Wednesday",
4: "Thursday",
5: "Friday",
6: "Saturday",
7: "Sunday"
}
if day_number in days:
print(f"Day {day_number}: {days[day_number]}")
else:
print("Invalid day number. Please enter a number between 1 and 7.")
Day 5: Friday
# Python doesn’t have a direct switch statement like some other languages
56 + 43 = 99
Question 17:- Program to display first 10 natural number and their sum.
sum=0
print("This is First 10 Natural Number")
for i in range(1,11):
sum=sum+i
print(i)
*
**
***
****
*****
n=int(input("Enter Number:-"))
for i in range(1,n+1):
for j in range(i):
print(i, end="")
print("")
Question 20:- Program to print stars sequence 3.
12345
1234
123
12
1