ch
Feedback
O Level Previous paper

O Level Previous paper

前往频道在 Telegram

https://youtube.com/@Satya806 सभी लोग इस Channel को Subscribe कर लो https://t.me/O_levelpaper Telegram group Quiz 👉https://t.me/o_levelsatya #M4-R5_Paper #M2R5 #O_Level #M3R5_Notes #M1R5Video #PaidClass_O_Level #O_Level_Notes #Satya_Sir

显示更多
732
订阅者
无数据24 小时
-17
-130
帖子存档
GCD of Two Numbers in Python (Program to Find HCF or GCD)

def find_gcd(num1, num2): while num2 != 0: remainder = num1 % num2 num1 = num2 num2 = remainder return num1 # Test the function number1 = int(input("Enter the first number: ")) number2 = int(input("Enter the second number: ")) result = find_gcd(number1, number2) print("The GCD of", number1, "and", number2, "is", result)

def find_gcd(num1, num2): if num2 == 0: return num1 else: return find_gcd(num2, num1 % num2) # Test the function number1 = int(input("Enter the first number: ")) number2 = int(input("Enter the second number: ")) result = find_gcd(number1, number2) print("The GCD of", number1, "and", number2, "is", result)

Enter the first number: 54 Enter the second number: 42 The GCD of 54 and 42 is 6

def find_gcd(num1, num2): gcd = 1 # Find the smaller of the two numbers smaller = min(num1, num2) # Start the loop from 2 up to the smaller number for i in range(2, smaller + 1): # Check if both numbers are divisible by the current value of i if num1 % i == 0 and num2 % i == 0: gcd = i return gcd # Test the function number1 = int(input("Enter the first number: ")) number2 = int(input("Enter the second number: ")) result = find_gcd(number1, number2) print("The GCD of", number1, "and", number2, "is", result)

# Python program for Fibonacci series def fibonacci_series(n): series = [0, 1] for i in range(2, n): series.append(series[i-1] + series[i-2]) return series # Test the program number = int(input("Enter the number of terms: ")) fib_series = fibonacci_series(number) print("Fibonacci Series:") print(fib_series)

# Python program for Fibonacci series using recursion def fibonacci_series(n): if n <= 0: return [] elif n == 1: return [0] elif n == 2: return [0, 1] else: series = fibonacci_series(n-1) series.append(series[-1] + series[-2]) return series # Test the program number = int(input("Enter the number of terms: ")) fib_series = fibonacci_series(number) print("Fibonacci Series:") print(fib_series)

Enter the number of terms: 8 Fibonacci Series: [0, 1, 1, 2, 3, 5, 8, 13]

# Program for Fibonacci sequence in Python def fibonacci_series(n): series = [0, 1] if n <= 2: return series[:n] for i in range(2, n): series.append(series[i-1] + series[i-2]) return series # Test the program number = int(input("Enter the number of terms: ")) fib_series = fibonacci_series(number) print("Fibonacci Series:") print(fib_series)

June 2023 Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Python Program to Print Current Month Calendar

# How to find factorial of a number in Python using while loop def factorial(n): if n == 0: return 1 else: result = 1 while n > 0: result *= n n -= 1 return result # Taking input from the user num = int(input("Enter a number: ")) # Checking if the number is negative if num < 0: print("Factorial cannot be calculated for negative numbers.") elif num == 0: print("Factorial of 0 is 1.") else: result = factorial(num) print("Factorial of", num, "is", result)

# Factorial in Python using for loop def factorial(n): result = 1 for i in range(1, n+1): result *= i return result # Taking input from the user num = int(input("Enter a number: ")) # Checking if the number is negative if num < 0: print("Factorial cannot be calculated for negative numbers.") elif num == 0: print("Factorial of 0 is 1.") else: result = factorial(num) print("Factorial of", num, "is", result)

इसको भी तीन तरीके से पुछा जा सकता है Types -01 Using for loop Find Factorial Number Types -02 Using while loop Find Factorial Number Types -03 Using Function Without Recursion

Enter a number: 10 Factorial of 10 is 3628800

# Factorial in Python using for loop def factorial(n): result = 1 for i in range(1, n+1): result *= i return result # Taking input from the user num = int(input("Enter a number: ")) # Checking if the number is negative if num < 0: print("Factorial cannot be calculated for negative numbers.") elif num == 0: print("Factorial of 0 is 1.") else: result = factorial(num) print("Factorial of", num, "is", result)

# Leap year code in Python using for loop def is_leap_year(year): if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0): return True else: return False # Get input from the user start_year = int(input("Enter the starting year: ")) end_year = int(input("Enter the ending year: ")) # Check leap year for each year in the range for year in range(start_year, end_year + 1): if is_leap_year(year): print(year, "is a leap year") else: print(year, "is not a leap year")

# Check leap year in Python using function def is_leap_year(year): if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: return True else: return False else: return True else: return False # Get input from the user year = int(input("Enter a year: ")) # Call the function and check if it's a leap year if is_leap_year(year): print(year, "is a leap year") else: print(year, "is not a leap year")

इसके पहले भी यह प्रश्न आ चुका है और फिर आने की संभावना है

Enter a year: 2022 2022 is not a leap year

O Level Previous paper - Telegram 频道 @o_levelpaper 的统计与分析