Source Code
Python 14 Aug 2025

Write a Python function that takes two lists and returns True if they have at least one common item.

                    
  # 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
Python 5 Aug 2025

Write a program which takes list of numbers as input and finds:
a) The largest number in the list
b) The smallest number in the list
c) Product of all the items in the list

                    
  # 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 2 Aug 2025

Write a Python program that takes list of numbers as input from the user and produces a cumulative list where each element in the list at any position n is sum of all elements at positions upto n-1.

                    
  # 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
Python 31 Jul 2025

Write a program that takes in a sentence as input and displays the number of words, number of capital letters, no. of small letters and number of special symbols.

                    
  # 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
Python 29 Jul 2025

Write a function that takes a string as parameter and returns a string with every successive repetitive character replaced by? e.g. school may become scho?l.

                    
  # 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 26 Jul 2025

Write a program to compute the wages of a daily laborer as per the following rules: -
Hours Worked Rate Applicable Upto first 8 hrs Rs100/-
(a) For next 4 hrs Rs30/- per hr extra
(b) For next 4 hrs Rs40/- per hr extra
(c) For next 4 hrs Rs50/- per hr extra
(d) For rest Rs60/- per hr extra

                    
  # 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
Python 25 Jul 2025

Write a program to multiply two numbers by repeated addition
Example 6*7 = 6+6+6+6+6+6+6

                    
  # 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
Python 25 Jul 2025

Write a function to obtain sum n terms of the following series for any positive integer value of X 1+x/1!+x2/2!+x3/3!+…

                    
  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
Python 24 Jul 2025

Write a function to obtain sum n terms of the following series for any positive integer value of X +X3 /3! +X5 /5! ! +X7 /7! + …

                    
  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
Python 24 Jul 2025

Write a program to print all Armstrong numbers in a given range. Note: An Armstrong number is a number whose sum of cubes of digits is equal to the number itself. E.g. 370=33+73+03

                    
  # 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
Python 13 Dec 2023

Python Program to print Hello World!

                    
  print("Hello World!")
  print('Hello World!')
  print("""Hello World!""")
  print('''Hello World!''')
                    
                    

▶️ Watch Now on YouTube
Python 17 Dec 2023

Python Program to Add Two Numbers

  
  # 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
Python 17 Dec 2023

Python Program to Add Two Numbers From the User

    
  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
Python 19 May 2023

Automate any Chat-Messenger with Python

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