# defining a function to calculate LCM def calculate_lcm(x, y): # selecting the greater number if x > y: greater = x else: greater = y print(greater) while(True): #infinite loop if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 print(greater) return lcm # taking input from…
import calendar # Enter the month and year #yy = int(input(“Enter year: “)) #mm = int(input(“Enter month: “)) # display the calendar #print(calendar.month(yy,mm)) # Enter the month and year yy = int(input(“Enter year: “)) # display the calendar for i in range(1,13): print(calendar.month(yy,i))
# Program to find leap year between two years as given by user def leap(Year): # Checking if the given year is leap year if(Year %4==0): if (Year % 100!=0): #print(“Given Year is a leap Year”); return(Year) else: if (Year%400==0): #print(“Given Year is a leap Year”); return(Year) else: return(0) # Else it is not a…
# Default function to implement conditions to check leap year def CheckLeap(Year): # Checking if the given year is leap year if((Year % 400 == 0) or (Year % 100 != 0) and (Year % 4 == 0)): print(“Given Year is a leap Year”); # Else it is not a leap year else: print (“Given Year is not a leap Year”) # Taking an input year from user Year = int(input(“Enter the number: “)) # Printing result CheckLeap(Year)
# Three sides of the triangle is a, b and c: a=float(input(‘Enter first side: ‘)) b=float(input(‘Enter second side: ‘)) c=float(input(‘Enter third side: ‘)) # calculate the semi-perimeter s=(a+b+c)/2 # calculate the area area=(s*(s-a)*(s-b)*(s-c))**0.5 print(‘The area of the triangle is %0.2f’%area) print(f’The area of the triangle is {area:.2f}’) print(‘The area of the triangle is {0}’,format(area)) print(‘The area of the triangle is {0:.2f}’.format(area))
# Simple Python program to understand the arithmetical operator addition # Here, we are storing the first input numbers in num1 num1 = input(‘Enter first number: ‘) # Here, we are storing the second input numbers in num2 num2 = input(‘Enter second number: ‘) # Here, we are declaring a variable sum to store the…
# Python program to print “Hello Python” print (‘Hello Python’)
Here are 20 long questions with detailed answers based on your syllabus: SECTION A: Introduction to Python 1. What is Python, and why is it widely used in programming? Python is a high-level, interpreted programming language known for its simplicity and readability. It was created by Guido van Rossum and first released in 1991. Python…
📌 List of Python Practical Exercises This is a structured list of Python exercises, covering basic to advanced topics with important mathematical and real-world problems like factorial, Armstrong number, prime number, and matrix operations. 🔹 1️⃣ Python Basics 1. Check Python Version ✅ Exercise: Write a program to display the installed Python version. 2. Variables…
Here’s a comprehensive list of Python programs covering everything from literals to advanced OOP concepts like inheritance, overloading, overriding, and polymorphism. 🔹 1️⃣ Python Literals 📌 Program: Demonstrate different types of literals. # Numeric Literals a = 10 # Integer b = 3.14 # Float c = 0b1010 # Binary d = 0o12 # Octal…