Python Practical

Module: M3-R5: Python Programming

Chapter: Numpy Basics

🔹 Python Practice Questions

Practice questions range from basic to advanced covering all topics of Python programming.

Q1: Write a Python program to print 'Hello World'.

Q2: Write a Python program to take input from the user and print it.

Q3: Write a Python program to add two numbers.

Q4: Write a Python program to swap two numbers without using a third variable.

Q5: Write a Python program to find the remainder when a number is divided by 2.

Q6: Write a Python program to check whether a number is even or odd.

Q7: Write a Python program to find the largest of three numbers.

Q8: Write a Python program to calculate the area of a circle given its radius.

Q9: Write a Python program to convert Celsius to Fahrenheit.

Q10: Write a Python program to check if a number is positive, negative, or zero.

Q11: Write a Python program to print all numbers from 1 to 50 using a loop.

Q12: Write a Python program to calculate the sum of first 10 natural numbers.

Q13: Write a Python program to print all even numbers between 1 and 100.

Q14: Write a Python program to print multiplication table of a number.

Q15: Write a Python program to find factorial of a number using a loop.

Q16: Write a Python program to find sum of digits of a number.

Q17: Write a Python program to check if a number is prime.

Q18: Write a Python program to print Fibonacci sequence up to n terms.

Q19: Write a Python program to print numbers divisible by 3 and 5 up to 100.

Q20: Write a Python program to reverse a number using a loop.

Q21: Write a Python program to count the number of vowels in a string.

Q22: Write a Python program to check if a string is a palindrome.

Q23: Write a Python program to reverse a string.

Q24: Write a Python program to remove vowels from a string.

Q25: Write a Python program to count the number of words in a string.

Q26: Write a Python program to capitalize the first letter of each word in a string.

Q27: Write a Python program to find the first occurrence of a substring in a string.

Q28: Write a Python program to replace all occurrences of a substring.

Q29: Write a Python program to check if a string starts with 'Py'.

Q30: Write a Python program to check if a string ends with 'thon'.

Q31: Write a Python program to sum all items in a list.

Q32: Write a Python program to multiply all items in a list.

Q33: Write a Python program to find the largest number in a list.

Q34: Write a Python program to find the smallest number in a list.

Q35: Write a Python program to count the number of elements in a list.

Q36: Write a Python program to sort a list in ascending order.

Q37: Write a Python program to sort a list in descending order.

Q38: Write a Python program to add an item to a tuple (hint: convert to list first).

Q39: Write a Python program to remove duplicates from a list.

Q40: Write a Python program to combine two lists.

Q41: Write a Python program to create a function that returns the square of a number.

Q42: Write a Python program to create a function that checks if a number is even.

Q43: Write a Python program to create a function that calculates factorial of a number.

Q44: Write a Python program to create a function that checks if a string is palindrome.

Q45: Write a Python program to create a function that calculates Fibonacci of n-th term.

Q46: Write a Python program to use *args in a function.

Q47: Write a Python program to use **kwargs in a function.

Q48: Write a Python program to create a recursive function for sum of n numbers.

Q49: Write a Python program to create a recursive function for factorial.

Q50: Write a Python program to create a function to find GCD of two numbers.

Q51: Write a Python program to create a new file and write some text in it.

Q52: Write a Python program to read the content of a file.

Q53: Write a Python program to append text to an existing file.

Q54: Write a Python program to count number of lines in a file.

Q55: Write a Python program to count number of words in a file.

Q56: Write a Python program to read a file line by line.

Q57: Write a Python program to write a list of strings to a file.

Q58: Write a Python program to copy content from one file to another.

Q59: Write a Python program to find the longest word in a file.

Q60: Write a Python program to count occurrences of a word in a file.

Q61: Write a Python program to import math module and calculate square root of a number.

Q62: Write a Python program to use random module to generate a random number between 1 and 100.

Q63: Write a Python program to use time module to get current time.

Q64: Write a Python program to use sys module to read command line arguments.

Q65: Write a Python program to create a numpy array from a list.

Q66: Write a Python program to create a numpy array of zeros.

Q67: Write a Python program to create a numpy array of ones.

Q68: Write a Python program to create a numpy array with a range of numbers.

Q69: Write a Python program to find shape and size of a numpy array.

Q70: Write a Python program to perform indexing and slicing on a numpy array.

Q71: Write a Python program to perform element-wise addition of two numpy arrays.

Q72: Write a Python program to perform element-wise multiplication of two numpy arrays.

Q73: Write a Python program to find maximum and minimum in a numpy array.

Q74: Write a Python program to calculate sum and mean of numpy array elements.

Q75: Write a Python program to reshape a numpy array.

Q76: Write a Python program to flatten a 2D numpy array.

Q77: Write a Python program to concatenate two numpy arrays.

Q78: Write a Python program to find unique elements in a numpy array.

Q79: Write a Python program to sort a numpy array.

Q80: Write a Python program to create a 2D numpy array of random numbers.

Q81: Write a Python program to implement recursive binary search.

Q82: Write a Python program to implement recursive linear search.

Q83: Write a Python program to calculate sum of digits of a number recursively.

Q84: Write a Python program to calculate power using recursion.

Q85: Write a Python program to print all permutations of a string using recursion.

Q86: Write a Python program to implement Tower of Hanoi problem.

Q87: Write a Python program to generate Fibonacci series recursively.

Q88: Write a Python program to find factorial using recursion.

Q89: Write a Python program to find GCD using recursion.

Q90: Write a Python program to implement quicksort using recursion.

Q91: Write a Python program to merge two dictionaries.

Q92: Write a Python program to sort a dictionary by keys.

Q93: Write a Python program to sort a dictionary by values.

Q94: Write a Python program to count frequency of elements in a list.

Q95: Write a Python program to remove empty strings from a list.

Q96: Write a Python program to check if a list is empty.

Q97: Write a Python program to flatten a nested list.

Q98: Write a Python program to convert list to tuple.

Q99: Write a Python program to convert tuple to list.

Q100: Write a Python program to convert string to list of words.

Q101: Write a Python program to convert list of characters to string.

Q102: Write a Python program to generate a list of squares using list comprehension.

Q103: Write a Python program to filter even numbers from a list using list comprehension.

Q104: Write a Python program to filter prime numbers from a list using list comprehension.

Q105: Write a Python program to create a dictionary from two lists.

Q106: Write a Python program to swap keys and values in a dictionary.

Q107: Write a Python program to find intersection of two lists.

Q108: Write a Python program to find union of two lists.

Q109: Write a Python program to remove duplicates from a list using set.

Q110: Write a Python program to implement a simple calculator using functions.

✅ Summary
  • These 100 questions cover all aspects of Python from basic to advanced.
  • Practice each question by writing code and testing it.
  • Topics include: Basics, Operators, Conditional Statements, Loops, Strings, Lists, Tuples, Functions, Recursion, Files, Modules, NumPy, and Dictionaries.
  • Helps in building strong programming fundamentals and problem-solving skills.
Quick Links