| GCD & LCM | Greatest common divisor (GCD) & Lowest Common Multiple (LCM). |
| factorial | Factorial of an input number by looping and by recursive functions |
| factors | Factors of an input number |
| Prime Numbers | Prime Numbers |
| Fibonacci | Fibonacci numbers by looping and by recursive functions |
| Sum of Digits | Sum of digits of an input number |
| Multiplication table | Multiplication table using nested for loops |
| strong number | Check input number is strong number or not |
| Armstrong number | Check input number is Armstrong number or not |
| Digit Cubes | Number equal to sum of cubes of its digits |
| recursion | Getting and setting recursion limits |
| Date | Exercise on Date & time |
| Salary | Employee Salary calculation |
a=int(input("Enter first Number"))
b=int(input("Enter second Number"))
c=int(input("Enter third Number"))
sum=a+b+c
print(sum)
m=int(input("Enter your marks"))
if(m>=90):
print("You have Passed with First Distinction")
else:
if(m>=60):
print("You have passed with Second Distinction")
else:
if(m>=35):
print("You have just passed work hard next time")
else:
print("Failed")
In place of using multiple if else , it is better to use elif. def my_binary(n):
i=''
while n>1:
a = n%2
n = n//2
i=str(a)+i
i= str(n%2) +i
print (i)
a=my_binary(156)
x=float(input("input number "))
y=int(x+0.5)
print(y)
Demonstrates multi-way decision logic using an if-elif-else ladder to evaluate numerical state.
# Program to check if a number is positive, negative, or zero
num = float(input("Enter a number: "))
if num > 0:
print("The number is Positive.")
elif num < 0:
print("The number is Negative.")
else:
print("The number is Zero.")
Combines a for loop with a modulo (%) conditional check to filter even numbers.
# Program to print all even numbers from 1 to 20
print("Even numbers between 1 and 20:")
for i in range(1, 21):
if i % 2 == 0:
print(i, end=" ")
Uses membership evaluation (in) and string validation methods to route inputs safely.
# Program to check whether a letter is a vowel or consonant
char = input("Enter a single letter: ").lower()
if len(char) == 1 and char.isalpha():
if char in 'aeiou':
print(f"'{char}' is a Vowel.")
else:
print(f"'{char}' is a Consonant.")
else:
print("Invalid input! Please enter a single alphabetic character.")
Demonstrates compound logical statements using the and operator to validate conditions.
# Program to find the largest among three numbers
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))
if num1 >= num2 and num1 >= num3:
largest = num1
elif num2 >= num1 and num2 >= num3:
largest = num2
else:
largest = num3
print(f"The largest number is: {largest}")
Uses a standard for loop with formatted strings to generate structured outputs.
# Program to generate multiplication table for a given number
num = int(input("Enter a number for the multiplication table: "))
print(f"\nMultiplication Table for {num}:")
for i in range(1, 11):
print(f"{num} x {i} = {num * i}")
Iterates through string characters and increments a counter variable when conditions match.
# Program to count total vowels in a sentence
text = input("Enter a sentence: ")
vowel_count = 0
for char in text.lower():
if char in 'aeiou':
vowel_count += 1
print(f"Total number of vowels: {vowel_count}")
Illustrates complex boundary evaluation using precedence with and & or operators.
# Program to check if a year is a leap year
year = int(input("Enter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print(f"{year} is a Leap Year.")
else:
print(f"{year} is NOT a Leap Year.")
Demonstrates accumulation logic inside a loop construct over a designated range.
# Program to calculate sum of numbers from 1 to N
n = int(input("Enter a positive integer N: "))
total = 0
for i in range(1, n + 1):
total += i
print(f"The sum of numbers from 1 to {n} is: {total}")
import urllib.request, json
key='YOUR_API_KEY' # Use your API key here
x = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url="
x= x + 'https://www.plus2net.com/python/pdf-grid.php'
x= x + '&strategy=desktop' # other value is mobile
x= x + '&locale=en'
x= x + '&key='+key
response = urllib.request.urlopen(x)
data = json.loads(response.read()) # get the return Json data
score = data["lighthouseResult"]["categories"]["performance"]["score"]
print(score)
fcp = data["loadingExperience"]["metrics"]["FIRST_CONTENTFUL_PAINT_MS"]["percentile"]
fid = data["loadingExperience"]["metrics"]["FIRST_INPUT_DELAY_MS"]["percentile"]
lcp = data["loadingExperience"]["metrics"]["LARGEST_CONTENTFUL_PAINT_MS"]["percentile"]
cls = data["loadingExperience"]["metrics"]["CUMULATIVE_LAYOUT_SHIFT_SCORE"]["percentile"]/100
print('fcp:',fcp,'fid: ',fid,'lcp:',lcp,'cls:',cls)
Learn Python basics through ONLINE classes

Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.