The document contains Python code examples for calculating a factorial, printing even numbers up to 10, generating a Fibonacci series based on a user-input number of terms, printing a number pyramid where the number of lines is input by the user, and calculating the average marks for three subjects for three students and determining if they passed or failed based on the average.
The document contains Python code examples for calculating a factorial, printing even numbers up to 10, generating a Fibonacci series based on a user-input number of terms, printing a number pyramid where the number of lines is input by the user, and calculating the average marks for three subjects for three students and determining if they passed or failed based on the average.
The document contains Python code examples for calculating a factorial, printing even numbers up to 10, generating a Fibonacci series based on a user-input number of terms, printing a number pyramid where the number of lines is input by the user, and calculating the average marks for three subjects for three students and determining if they passed or failed based on the average.
1. Find the factorial of a number a= int(input(“Enter the number: “)) fact =1 for i in range(1, a+1): fact = fact *i print(“Factorial of”, a, “is”, fact) 2. Write a program to print even numbers up to 10 for num in range(2, 10, 2): print(“Number= “, num) 3. Write a program to generate the Fibonacci series n = int(input(“Enter the number of terms: “)) f1, f2 = 0, 1 f3 = f1+f2 print(“Fibonacci series of first”, n, “terms”) print(f1) print(f2 for i in range (3, n+1): print(f3) f1 = f2 f2 = f3 f3 = f1 + f2 4. Write a program that print the following pyramid on the screen. The number of lines must be obtained from the user as input. 1 22 333 4444 55555 n = int(input(“Enter the step size: “)) for i in range(1, n+1): for j in range(1, i +1): print(i, end = ‘ ‘) print() 5. Write a python program to accept the marks for the three subjects’ math’s, Physics and Biology for three students and calculate the average marks. If the average marks is >50 , print pass and <50, Fail