Loop practice questions in Python - Level 2

WAP stands for Write A Program

  1. WAP in Python to print only the string datatype from the given list
       a = [‘Samarth’, ‘Kunal’, ‘Jatin’, 12, 75.5]
  2. WAP in Python to whether an input number is a Armstrong number or not.
    An Armstrong number is a number that is equal to the sum of its digits, each raised to the power of the number of digits in the number. 
    For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.
    Single-digit numbers: All single-digit numbers (0-9) are Armstrong numbers.
    Three-digit numbers: 153, 370, 371, and 407 are three-digit Armstrong numbers. 
    Four-digit numbers: 1634, 8208, and 9474 are four-digit Armstrong numbers.
  3. d = {5:16, 3:9, 10:81, 1:0, 6:36}
    WAP in python to print the sum of only those keys from the dictionary for which the value is NOT a square of the keys
  4. WAP to take a number as input from the user and print the sum of its’ digits.
  5. li1 =[10, 20, 50, 80, 60]
    li2 = [50, 88, 95, 76, 81, 10, 60, 50, 60]
    WAP in Python to print the common elements between the given two lists.
    Maintain the order of the elements
  6. d = {“Samarth”:[45, 60, 50, 70], “Jatin”: [90, 95, 93, 91, 90], “Nishant”:[93, 99, 98, 97, 91]}
    WAP in Python to calculate the average of the marks for each student and print it.
  7. Name = [“Samarth”, “Jatin”, “Nishant”, “Harsg”, “Dabru”, “Kunal”]
    Roll_no = [1, 20, 13, 4, 9, 11]
    WAP to search if a particular student name/rollno is present in the list or not. Take name/rollno as input and print the corresponding data.
    For e.g.
    If user enters 4, print Harsh
    If user enters Kunal, print 11
    If user enters Mayank, print “Does not Exist”
     
  8. WAP to print the digits of an input number in word format.
      i/p: Enter any number 85200
      o/p: 
    Eight
    Five
    Two
    Zero
    Zero
  9. WAP to create a fibonacci sequence of n digits. Take n as input.
  10. WAP to convert a decimal number to binary number.
        For e.g. i/p = 10
                 o/p = 1010