# Python function that takes two lists and returns True if they have at least one common item.
def common_item(list1, list2):
for item in list1:
if item in list2:
return True
return False
# Example usage:
list_a = [1, 2, 3, 4]
list_b = [4, 5, 6]
print(common_item(list_a, list_b))
▶️ Watch Now on YouTube
# Finds the largest, smallest and product from a list
numbers = list(eval(input("Enter numbers separated by comma: ")))
largest = max(numbers)
smallest = min(numbers)
product = 1
for num in numbers:
product *= num
print("Original List:", numbers)
print("Largest Number:", largest)
print("Smallest Number:", smallest)
print("Product of All Numbers:", product)
▶️ Watch Now on YouTube
# Python Program: Cumulative Sum List
numbers = list(eval(input("Enter numbers separated by comma: ")))
s = 0
cumulative = []
for n in numbers:
cumulative.append(s)
s = s + n
print("Original List:", numbers)
print("Cumulative List:", cumulative)
▶️ Watch Now on YouTube
# Program Count Words, Capital Letters, Small Letters, Digits, and Special Symbols
sentence = input("Enter a sentence: ")
word_count = 0
capital_letters = 0
small_letters = 0
digits = 0
special_symbols = 0
word_count = len(sentence.split())
# Loop through each character in the sentence
for char in sentence:
if char.isupper():
capital_letters += 1
elif char.islower():
small_letters += 1
elif char.isdigit():
digits += 1
elif not char.isspace() and not char.isalnum():
special_symbols += 1
# Display the results
print("\n--- Result ---")
print("Number of words :", word_count)
print("Number of capital letters:", capital_letters)
print("Number of small letters :", small_letters)
print("Number of digits :", digits)
print("Number of special symbols:", special_symbols)
▶️ Watch Now on YouTube
# Replace every successive repetitive character with '?' in Python
def replace_repetitions(text):
result = ""
for i in range(len(text)):
if i > 0 and text[i] == text[i - 1]:
result += "?"
else:
result += text[i]
return result
text = replace_repetitions('school')
print(text)
▶️ Watch Now on YouTube
# Python Program to compute the wages of a daily laborer as per the following rules:
name = input("Enter the name of the labourer: ")
hours = int(input("Enter the number of hours worked: "))
wage = 0
# Calculate wages based on hours worked
if hours <= 8:
wage = hours * 100
elif hours <= 12:
wage = 8 * 100 + (hours - 8) * 130 # ₹100 base + ₹30 extra
elif hours <= 16:
wage = 8 * 100 + 4 * 130 + (hours - 12) * 140 # ₹100 base + ₹40 extra
elif hours <= 20:
wage = 8 * 100 + 4 * 130 + 4 * 140 + (hours - 16) * 150 # ₹100 base + ₹50 extra
else:
wage = 8 * 100 + 4 * 130 + 4 * 140 + 4 * 150 + (hours - 20) * 160 # ₹100 base + ₹60 extra
# Display output
print("Labourer Name:", name)
print("Worked Hours:", hours)
print("Total Wages: Rs", wage)
▶️ Watch Now on YouTube
# Program to multiply two numbers using repeated addition
# Input from user
x = int(input("Enter the number to be added repeatedly: "))
n = int(input("Enter how many times to add it: "))
total = 0
# Repeated addition
for i in range(n):
total = total + x
# Showing repeated addition result
print("Sum of two numbers using repeated addition is: ", total)
▶️ Watch Now on YouTube
def exp_series(x, n):
sum = 1.0 # Starting with the first term (i = 0)
term = 1.0 # To keep track of x^i / i!
for i in range(1, n + 1):
term *= x / i # Efficient way to calculate x^i / i!
sum += term
return sum
# Example usage:
x = 3
n = 5
print("Sum of series:", exp_series(x, n))
▶️ Watch Now on YouTube
import math
# Input from the user
x = int(input("Enter the value of X: "))
n = int(input("Enter number of terms: "))
sum = 0
# Loop for n terms
for i in range(n):
power = 2 * i + 1 # Only odd powers: 1, 3, 5, ...
fact = math.factorial(power)
term = (x ** power) / fact
sum += term # Add each term to the sum
# Final Output
print("Sum of the series is", sum)
▶️ Watch Now on YouTube
# Program to print Armstrong numbers in a given range
start = int(input("Enter starting number: "))
end = int(input("Enter ending number: "))
for n in range(start, end + 1):
temp = n
sum = 0
digits = len(str(n))
while temp != 0:
rem = temp % 10
sum += rem ** digits
temp = temp // 10
if n == sum:
print(n, end=' ')
▶️ Watch Now on YouTube
print("Hello World!")
print('Hello World!')
print("""Hello World!""")
print('''Hello World!''')
▶️ Watch Now on YouTube
# This Python program adds two numbers
num1 = 14
num2 = 25
sum = num1 + num2
print('The sum of ', num1, ' and ', num2, ' is ', sum)
▶️ Watch Now on YouTube
num1 = input('Enter first number: ')
num2 = input('Enter second number: ')
# Add two numbers
sum = float(num1) + float(num2)
# Display the sum
print('The sum of ', num1, ' and ', num2, ' is ', sum)
▶️ Watch Now on YouTube
In order to access the Python library, you need to install it first : pip install pyautogui
'''
Automate any Chat-Messenger with Python
Author : DEEPAK RAJ
'''
# import the necessary module
import pyautogui
import time
time.sleep(5)
text = '☠ You Are Hack ☠'
while True:
pyautogui.typewrite(text)
pyautogui.press('enter')
time.sleep(1)
▶️ Watch Now on YouTube