0% found this document useful (0 votes)
6 views

Zunaid Python Code

Uploaded by

alamzunaid448
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Zunaid Python Code

Uploaded by

alamzunaid448
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#write a program to find the factorial of any given number

a = int(input("Enter a number: "))


b=1

if a == 0 or a == 1:
b=1
else:
for c in range(1, a + 1):
b=b*c

print(f"The factorial of {a} is {b}.")

2-
#write a program to generate fibbonacci series

a=0
b=1
c=0
for d in range (0, 10):
if d < 50 :
c = a + b;
a=b
b=c
print (c)
3-
#write a python program to find the cube of any given no. using for loop

a = int(input("Enter a number: "))


cube = 0
for i in range(1):
cube = a*a*a
print(f"The cube of {a} is {cube}")

4-
# write the program to print the following pattern
1
12
123
1234
12345

n = 10
for i in range(1, n+1):
for j in range(1, i+1):
print(j, end="")
print()
5-
# write a program to convert a given temp in Fahrenheit to Celsius
Fahrenheit = float(input("Enter temperature in Fahrenheit: "))

celsius = (fahrenheit - 32) * 5 / 9

print(f"{fahrenheit}°F is equal to {celsius:.2f}°C")

You might also like