Loop practice questions in Python - Level 1

WAP stands for Write A Program

  1. WAP to print the first and last character of all the names in the given list
    l = [‘Mayank’, ‘Aniket’, ‘Saurabh’, ‘Rahul’]

  2. WAP to print the powers of first n whole numbers
    Take power and n from the user as input.

  3. WAP to print the data type of each element in the given tuple.
    t = (‘Someone’, 34, ‘hi’, 12.983, 34 +9j)

  4. WAP to print all the two digit even numbers which are also a multiple of 3.

  5. WAP to print the sum of individual tuples separately.
    marksList = [(23, 24, 31), (56, 34, 53), (42, 58, 31)]

  6. WAP to print all the multiples of 2 and 7 between 30 and 300

  7. t = (23, 45, 67, 90, 12, 10)
    WAP to print even/odd for all the numbers.

  8. Take a string input from the user. Reverse the string without using slicing.

  9. t = (23, 45, 67, 90, 12, 10)
    WAP to print the 2nd digit of all the numbers from this collection.

  10. l = [2, 5, ‘a’, 5, ‘r’, 7, ‘m’, ‘t’, ‘4’]
    WAP to print all the numerical data.

  11. WAP in Python to calculate the sum of all numbers from 1 to n.
    Take n as input from the user.

  12. WAP in Python to count the total number of digits in a number. Take number as input.

  13. WAP in Python that accepts a word from the user and prints the characters of the word in reverse fashion.

  14. WAP in Python to find the factorial of a given number. Take the number as input.

  15. Print the following pattern using for loop.
    5 4 3 2 1
    4 3 2 1
    3 2 1
    2 1
    1