Python Assignment Questions

Variables
  1. Take your age as input and print:My age is 20

  2. Take two numbers as input and print both numbers.
  3. Take your favorite color as input and print:He wear blue shirt
  4. Take your mobile number as input and print it.

 

  1. Add 25 and 15.
  2. Subtract 18 from 50.
  3. Multiply 12 by 8.
  4. Divide 100 by 5.
  5. Find the sum of 45, 20, and 15.
  6. Multiply 9 by 6 and then add 10.
  7. Subtract 25 from the product of 8 and 9.
  8. Divide 144 by 12 and then multiply the result by 3.
  9. Find the result of (20 + 10) / 5.
  10. Find the result of (15 * 4) - 20.
  11. Calculate 250 + 150 - 100.
  12. Calculate 30 * 5 / 2.
  13. Find the result of 80 / 4 + 10.
  14. Calculate (50 - 20) * 3.
  15. Find the result of (100 + 50) / 10.
  1. Check whether a person is eligible to vote or not.
  2. Check whether a student has passed or failed (passing marks = 40).
  3. Find the greater number between two numbers.
  4. Check whether a number is positive, negative, or zero.
  5. Check whether a number is even or odd.
  6. Check whether a person is eligible for a driving license (age ≥ 18).
  7. Check whether a number lies between 10 and 50.
  8. Check whether a student is eligible for admission (marks ≥ 60 and age ≥ 17).
  9. Check whether a customer gets a discount (purchase amount ≥ ₹2000).
  10. Check whether a number is divisible by both 3 and 5.
  11. Check whether a number is divisible by 3 or 5.
  12. Check whether a user can log in using the correct username and password.
  13. Check whether a person is a senior citizen (age ≥ 60).
  14. Check whether a year is a leap year.
  15. Check whether a day entered by the user is a weekend or a working day.
  16. Check whether a student qualifies for a scholarship (marks > 85 and attendance > 75%).
  17. Check whether a number is a three-digit number.
  18. Check whether a person can enter a movie theater (age ≥ 18 or accompanied by a guardian).
  19. Check whether a number is not equal to zero.
  20. Check whether a person is eligible for a loan (salary ≥ ₹30,000 and age between 21 and 60).
  21. Check whether a triangle is valid (sum of any two sides greater than the third side).
  22. Check whether a character is a vowel or a consonant.
  23. Check whether a user is eligible for free shipping (order value > ₹500).
  24. Check whether a temperature indicates a hot day (> 35°C), normal day, or cold day (< 15°C).
  25. Check whether a person is eligible for a sports competition (age between 15 and 25 and medically fit).

 

  1. Print all even numbers from 1 to 50.
  2. Print all odd numbers from 1 to 50.
  3. Print the multiplication table of a given number.
  4. Find the sum of numbers from 1 to 100.
  5. Find the sum of all even numbers from 1 to 100.
  6. Find the sum of all odd numbers from 1 to 100.
  7. Count how many numbers are divisible by 5 between 1 and 100.
  8. Print the square of numbers from 1 to 20.
  9. Print the cube of numbers from 1 to 10.
  10. Calculate the factorial of a given number.
  11. Reverse counting from a given number to 1.
  12. Print all numbers divisible by both 3 and 5 between 1 and 100.
  13. Count the number of digits in a given number.
  14. Find the sum of digits of a given number.
  15. Print each character of a string on a new line.
  16. Count the number of vowels in a string.
  17. Count the number of consonants in a string.
  18. Find the frequency of a specific character in a string.
  19. Find the largest number in a list.
  20. Find the smallest number in a list.
  21. Count positive, negative, and zero values in a list.
  22. Remove duplicates from a list using a loop.
  1. Basic String Assignments

    1. Input a string and print it.
    2. Find the length of a string.
    3. Convert a string to uppercase.
    4. Convert a string to lowercase.
    5. Count the number of characters in a string.
    6. Print the first character of a string.
    7. Print the last character of a string.
    8. Print the first 5 characters of a string.
    9. Reverse a string.
    10. Check whether a string is empty or not.

    Searching & Counting

    1. Count the number of vowels in a string.
    2. Count the number of consonants in a string.
    3. Count the number of spaces in a string.
    4. Count the number of digits in a string.
    5. Count the number of special characters in a string.
    6. Find the frequency of a specific character.
    7. Count how many times a word appears in a sentence.
    8. Check whether a character exists in a string.
    9. Find the position of a character in a string.
    10. Find the position of a word in a sentence.

    String Manipulation

    1. Replace one character with another.
    2. Replace a word in a sentence.
    3. Remove all spaces from a string.
    4. Remove leading and trailing spaces.
    5. Concatenate two strings.
    6. Repeat a string N times.
    7. Split a sentence into words.
    8. Join a list of words into a string.
    9. Remove a specific character from a string.
    10. Remove all vowels from a string.

    String Comparison

    1. Compare two strings and check if they are equal.
    2. Check whether two strings are equal ignoring case.
    3. Check whether a string starts with a given character or word.
    4. Check whether a string ends with a given character or word.
    5. Check whether a string contains a specific substring.

    Palindrome & Patterns

    1. Check whether a string is a palindrome.
    2. Check whether a string reads the same forward and backward.
    3. Print each character of a string on a new line.
    4. Print characters at even indexes.
    5. Print characters at odd indexes.

    Intermediate Assignments

    1. Count the number of words in a sentence.
    2. Find the longest word in a sentence.
    3. Find the shortest word in a sentence.
    4. Capitalize the first letter of each word.
    5. Swap the case of each character.
    6. Remove duplicate characters from a string.
    7. Check whether two strings are anagrams.
    8. Find the most frequently occurring character.
    9. Extract all numbers from a string.
    10. Check whether a string contains only alphabets, only digits, or both.

    Challenge Assignments

    1. Create an email validator.
    2. Create a password strength checker.
    3. Convert a sentence into title case.
    4. Count uppercase and lowercase letters separately.
    5. Find all vowels and their positions in a string.
    6. Find all occurrences of a substring.
    7. Compress a string (aaabbc → a3b2c1).
    8. Find the first non-repeating character.
    9. Find the first repeating character.
    10. Reverse the order of words in a sentence.