1.Develop Python Code to print odd numbers up to 100.
##Using 'for' loop
a = 100
for i in range(1,a,2):
print(i)

##Using 'while' loop
a = 1
while a < 100:
print(a)
a = a+2
    2.Develop Python Code to read any number and print even numbers up to it.
    ##Using 'for' loop
    a = int(input("Enter any Number"))
    for i in range(2,a+1,2):
    print(i)

    ##Using 'while' loop
    a = int(input("Enter any Number :"))
    b = 2
    while b <= a:
    print(b)
    b = b+2
      3.Develop Python Code to read any number and print the sum of even numbers and odd numbers up to it.
      ##Using 'for' loop
      a = int(input("Enter any number :"))
      b = c = 0
      for i in range(1,a,2):
      b = b+i
      print("Sum of odd NUmber are :"+str(b))
      for i in range(2,a+1,2):
      c = c+i
      print("Sum of even NUmber are :"+str(c))

      ##Using 'while' loop
      a = int(input("Enter any number :"))
      b = 1
      c = 2
      d = e = 0
      while b <= a:
      d = d+b
      b = b+2
      while c <= a:
      e = e+c
      c = c+2
      print("Sum of odd NUmber are :"+str(d),"Sum of even Number are :"+str(e))
        4.Develop Python Code to read any number and print count of even numbers and odd numbers up to it.
        ##Using 'for' loop
        a = int(input("Enter any Number :"))
        b = c = 0
        for i in range(1,a+1,2):
        b = b+1
        for i in range(2,a+1,2):
        c = c+1
        print("Count of Odd Numbers :"+str(b),"Count of Even Numbers :"+str(c))

        ##Using 'while' loop
        a = int(input("Enter any number :"))
        b = 1
        c = 2
        d = e = 0
        while b <= a:
        d = d+1
        b = b+2
        while c <= a:
        e = e+1
        c = c+2
        print("Count of odd NUmber are :"+str(d),"Count of even NUmber are :"+str(e))
          5.Develop Python Code to ready two numbers say x and y, print numbers in between them.
          ##Using 'for' loop
          a = int(input("Enter any Number :"))
          b = int(input("Enter any Number :"))
          for i in range(a+1,b):
          print(i,end=" ")

          ##Using 'while' loop
          a = int(input("Enter any Number :"))
          b = int(input("Enter any Number :"))
          while a < b-1:
          a = a+1
          print(a)
            6.Develop Python Code to ready two numbers say x and y, count even and odd numbers in between them.
            ##Using 'for' loop
            a = int(input("Enter any Number :"))
            b = int(input("Enter any Number :"))
            c = d = 0
            for i in range(a+1,b):
            if i%2 == 1:
            c = c+1
            else:
            d = d+1
            print("Count of odd NUmber are :"+str(c),"Count of even NUmber are :"+str(d))

            ##Using 'while' loop
            a = int(input("Enter any Number :"))
            b = int(input("Enter any Number :"))
            while a < b-1:
            a = a+1
            if a%2 == 1:
            c = c+1
            else:
            d = d+1
            print("Count of odd NUmber are :"+str(c),"Count of even NUmber are :"+str(d))
              7.Develop Python Code to demonstrate while loop with else block.
              ##Using 'while' loop
              a = 1
              while a < 6:
              print(a)
              a = a+1
              else:
              print("Loop completed.")
                8.Develop Python Code to demonstrate for loop with else block.
                ##Using 'for' loop
                a = 6
                for i in range(1,a):
                print(i)
                else:
                print("Loop completed.")
                  9. Write a python to create an infinite loop, it should stop when the input is zero.
                  ##Using 'while' loop
                  a = input("Enter any Number :")
                  while a != "0":
                  a = input("Enter any Number :")
                    10.Develop Python Code to print only even numbers using continue statement.
                    ##Using 'for' loop
                    a = int(input("Enter any Number :"))
                    for i in range(1,a+1):
                    if i%2 == 1:
                    continue
                    print(i)

                    ##Using 'while' loop
                    a = int(input("Enter any Number :"))
                    b = 0
                    while b < a:
                    b = b+1
                    if b%2 == 1:
                    continue
                    print(b)
                      11.Develop Python Code to demonstrate loop with else block and break statement.
                      ##Using 'for' loop
                      a = 10
                      for i in range(1,a):
                      if i == 6:
                      break
                      print(i)
                      else:
                      print("Loop completed.")

                      ##Using 'while' loop
                      a = 1
                      while a < 10:
                      if a == 6:
                      break
                      print(a)
                      a = a+1
                      else:
                      print("Loop completed.")
                        12.Develop Python Code to demonstrate loop with pass statement.
                        ##Using 'for' loop
                        a = int(input("Enter any Number :"))
                        for i in range(1,a+1):
                        if i == 3:
                        pass
                        print(i)

                        ##Using 'while' loop
                        a = int(input("Enter any Number :"))
                        b = 0
                        while b < a:
                        b = b+1
                        if b == 4:
                        pass
                        print(b)
                          13.Develop Python Code to read some numbers and find maximum and minimum number.
                          ##Using 'for' loop
                          a = b = c = int(input("Enter 1 Number :"))
                          for i in range(2,11):
                          a = int(input("Enter "+str(i)+" Number :"))
                          if a <= b:
                          b = a
                          if a >= c:
                          c = a
                          print("The minimum value is :"+str(b),"The maximum value is :"+str(c))

                          ##Using 'while' loop
                          a = b = c = int(input("Enter 1 Number :"))
                          d = 1
                          while d < 11:
                          a = int(input("Enter "+str(i)+" Number :"))
                          if a <= b:
                          b = a
                          if a >= c:
                          c = a
                          d = d+1
                          print("The minimum value is :"+str(b),"The maximum value is :"+str(c))
                            14.Develop Python Code to read any binary number and convert it to decimal number.
                            ##Using 'for' loop
                            a = int(input("Enter binary Number :"))
                            c = 0
                            for i in range(len(str(a))):
                            b = a%10
                            if b == 1:
                            c = c+(2**i)
                            a = a//10
                            print(c)

                            ##Using 'while' loop
                            a = int(input("Enter binary Number :"))
                            c = e = 0
                            d = len(str(a))
                            while d > e:
                            b = a%10
                            if b == 1:
                            c = c+(2**e)
                            a = a//10
                            e = e+1
                            print(c)
                              15.Develop Python Code to read any number and find whether it is square root or cube root.
                              ( if input is 25 then square root is 5, if input is 64 then cube root 4).
                              ##Using 'for' loop
                              a = int(input("Enter any Number :"))
                              for i in range(1,a+1):
                              if (a//i)//i == i:
                              print("Given Number is the Cube root of "+str(i))
                              if a//i == i:
                              print("Given Number is the Square root of "+str(i))

                              ##Using 'while' loop
                              a = int(input("Enter any Number :"))
                              b = 1
                              while b < a:
                              if (a//b)//b == b:
                              print("Given Number is the Cube root of "+str(b))
                              if a//b == b:
                              print("Given Number is the Square root of "+str(b))
                              b = b+1
                                16.Develop Python Code to find ones complement of a binary number.
                                ##Using 'for' loop
                                a = int(input("Enter any Binary Number :"))
                                b = ""
                                for i in range(len(str(a))):
                                if a%10 == 0:
                                b = str(1)+b
                                else:
                                b = str(0)+b
                                a = a//10
                                print("1's complement form is :"+str(b))

                                ##Using 'while' loop
                                a = int(input("Enter any Binary Number :"))
                                b = ""
                                while a:
                                if a%10 == 0:
                                b = str(1)+b
                                else:
                                b = str(0)+b
                                a = a//10
                                print("1's complement form is :"+str(b))
                                  17.Develop Python Code convert a digits into binary values.
                                  ##Using 'for' loop
                                  a = b = int(input("Enter any Number"))
                                  c = ""
                                  for i in range(a):
                                  c = str(a%2)+c
                                  a = a//2
                                  if a == 0:
                                  break
                                  print("Entered Number is :"+str(b)+"\nBinary form is :"+str(c))

                                  ##Using 'while' loop
                                  a = b = int(input("Enter any Number :"))
                                  c = ""
                                  while a:
                                  c = str(a%2)+c
                                  a = a//2
                                  print("Entered Number is :"+str(b)+"\nBinary form is :"+str(c))
                                    18.Develop Python Code to print leap years up to 1000.
                                    ##Using 'for' loop
                                    a = 1000
                                    for i in range(4,a+1,4):
                                    print(i,end=" ")

                                    ##Using 'while' loop
                                    a = 4
                                    while a <= 1000:
                                    print(a,end=" ")
                                    a = a+4
                                      19.Develop Python Code to read any float number and print its floor and ceil values.
                                      import math
                                      a = float(input("Enter any Number :"))
                                      b = math.ceil(a)
                                      c = math.floor(a)
                                      print("ceil value :"+str(b)," Floor value is :"+str(c))
                                        20.Develop Python Code to check an entered number is perfect number of not.
                                        (A perfect number is something that the factors sum is number itself, for example if input is 6 then factors sum is 1+2+3=6 is the number itself).
                                        ##Using 'for' loop
                                        a = int(input("Enter any Number :"))
                                        b = 0
                                        for i in range(1,a):
                                        if a%i == 0:
                                        b = b+i
                                        if b == a:
                                        print("Perfect Number")
                                        else:
                                        print("Not a perfect Number")

                                        ##Using 'while' loop
                                        a = int(input("Enter any Number :"))
                                        b = 0
                                        c = 1
                                        while c < a:
                                        if a%c == 0:
                                        b = b+c
                                        c = c+1
                                        if b == a:
                                        print("Perfect Number")
                                        else:
                                        print("Not a perfect Number")
                                          21.Develop Python Code to verify a number is prime or not.
                                          ##Using 'for' loop
                                          a = int(input("Enter any Number :"))
                                          b = 0
                                          for i in range(1,a+1):
                                          if a%i == 0:
                                          b = b+1
                                          if b == 2:
                                          print("Prime Number")
                                          else:
                                          print("Not a Prime Number")

                                          ##Using 'while' loop
                                          a = int(input("Enter any Number :"))
                                          b = 0
                                          c = 1
                                          while c <= a:
                                          if a%c == 0:
                                          b = b+1
                                          c = c+1
                                          if b == 2:
                                          print("Prime Number")
                                          else:
                                          print("Not a Prime Number")
                                            22.Develop Python Code to verify a number is Armstrong number or not.
                                            ##Using 'for' loop
                                            a = e = int(input("Enter any Number :"))
                                            b = 0
                                            l = len(str(a))
                                            for i in range(l):
                                            c = a%10
                                            b = b+(c**l)
                                            a = a//10
                                            if b == e:
                                            print("Armstrong Number")
                                            else:
                                            print("Not a Armstrong Number")

                                            ##Using 'while' loop
                                            a = e = int(input("Enter any Number :"))
                                            b = 0
                                            c = l = len(str(a))
                                            while c > 0:
                                            d = a%10
                                            b = b+(d**l)
                                            c = c-1
                                            a = a//10
                                            if b == e:
                                            print("Armstrong Number")
                                            else:
                                            print("Not a Armstrong Number")
                                              23.Develop Python Code to verify a number is strong number or not.
                                              ##Using 'for' loop
                                              a = s = int(input("Enter any Number :"))
                                              b = 0
                                              c = len(str(a))
                                              for i in range(c):
                                              d = a%10
                                              fac = 1
                                              for j in range(1,d+1):
                                              fac = fac*j
                                              a = a//10
                                              b = b+fac
                                              if b == s:
                                              print("Strong Number")
                                              else:
                                              print("Not a Strong Number")

                                              ##Using 'while' loop
                                              a = s = int(input("Enter any Number :"))
                                              b = 0
                                              c = len(str(a))
                                              while c > 0:
                                              d = a%10
                                              fac = 1
                                              while d > 0:
                                              fac = fac*d
                                              d = d-1
                                              a = a//10
                                              b = b+fac
                                              c = c-1
                                              if b == s:
                                              print("Strong Number")
                                              else:
                                              print("Not a Strong Number")
                                                24.Develop Python Code to find HCF of two numbers.
                                                ##Using 'for' loop
                                                a = int(input("Enter any Number :"))
                                                b = int(input("Enter any Number :"))
                                                c = 0
                                                for i in range(1,a+b+1):
                                                if a%i == 0 and b%i == 0:
                                                c = i
                                                print("HCF is :"+str(c))

                                                ##Using 'while' loop
                                                a = int(input("Enter any Number :"))
                                                b = int(input("Enter any Number :"))
                                                c = 0
                                                sum = 1
                                                while sum < a+b:
                                                if a%sum == 0 and b%sum == 0:
                                                c = sum
                                                sum = sum+1
                                                print("HCF is :"+str(c))
                                                  25.Develop Python Code to find LCM of two numbers.
                                                  ##Using 'for' loop
                                                  a = int(input("Enter any Number :"))
                                                  b = int(input("Enter any Number :"))
                                                  c = 0
                                                  for i in range(1,a+b+1):
                                                  if a%i == 0 and b%i == 0:
                                                  c = i
                                                  print("LCM is :"+str((a*b)//c))

                                                  ##Using 'while' loop
                                                  a = int(input("Enter any Number :"))
                                                  b = int(input("Enter any Number :"))
                                                  c = 0
                                                  sum = 1
                                                  while sum < a+b:
                                                  if a%sum == 0 and b%sum == 0:
                                                  c = sum
                                                  sum = sum+1
                                                  print("LCM is :"+str((a*b)//c))
                                                    26.Develop Python Code to verify a number is palindrome or not.
                                                    ##Using 'for' loop
                                                    a = int(input("Enter any Number"))
                                                    b = ''
                                                    e = str(a)
                                                    d = len(e)
                                                    for i in range(d):
                                                    c = a % 10
                                                    b = b+str(c)
                                                    a = a//10
                                                    if b == e:
                                                    print("Its a palindrome number")
                                                    else:
                                                    print("it is not a palindrome number")

                                                    ##Using 'while' loop
                                                    a = int(input("Enter any Number"))
                                                    b = ''
                                                    e = str(a)
                                                    d = len(e)
                                                    while d > 0:
                                                    c = a % 10
                                                    b = b+str(c)
                                                    a = a//10
                                                    d = d-1
                                                    if b == e:
                                                    print("Its a palindrome number")
                                                    else:
                                                    print("it is not a palindrome number")
                                                      27.Develop Python Code to print a particular month calendar.
                                                      ##Using 'for' loop

                                                      ##Using 'while' loop
                                                        28.Develop Python Code to read a number and an integer and count how may time that integer occur in the number.
                                                        ##Using 'for' loop
                                                        a = int(input("Enter any Number :"))
                                                        c = str(a)
                                                        b = int(input("Enter any Integer :"))
                                                        d = 0
                                                        for i in c:
                                                        if i == str(b):
                                                        d = d+1
                                                        print("The Number Occurs "+str(d)+" times")

                                                        ##Using 'while' loop
                                                        a = int(input("Enter any Number :"))
                                                        c = len(str(a))
                                                        b = int(input("Enter any Integer :"))
                                                        d = 0
                                                        while c > 0:
                                                        if a%10 == b:
                                                        d = d+1
                                                        a = a//10
                                                        c = c-1
                                                        print("The Number Occurs "+str(d)+" times")
                                                          29.Develop Python Code to read a number and find the number of occurrences of each digit in that number.
                                                          ##Using 'for' loop
                                                          a = int(input("Enter any Number :"))
                                                          b = ""
                                                          for i in str(a):
                                                          c = 0
                                                          for j in str(a):
                                                          if i == j:
                                                          c = c+1
                                                          if i not in b:
                                                          print(str(i)+" occurs "+str(c)+" times")
                                                          b = b+i
                                                            30.Develop Python Code to read a number and verity whether the integers in that number in ascending order or not.
                                                            ##Using 'for' loop
                                                            a = int(input("Enter any Number :"))
                                                            b = a//10
                                                            for i in str(a):
                                                            if a%10 < b%10:
                                                            break
                                                            a = a//10
                                                            b = b//10
                                                            else:
                                                            print("ascending order")

                                                            ##Using 'while' loop
                                                            a = int(input("Enter any Number :"))
                                                            b = a//10
                                                            c = len(str(a))
                                                            while c > 0:
                                                            if a%10 < b%10:
                                                            break
                                                            a,b = a//10,b//10
                                                            c = c-1
                                                            else:
                                                            print("ascending order")

                                                              *Questions Prepared by--Srikanth.D

                                                              Mentor in IT,Dept of IT,RGUKT-SRIKAKULAM
                                                              duppada8@rguktsklm.ac.in

                                                                  30

                                                                  Projects

                                                                  300

                                                                  Minutes Of Support

                                                                  5

                                                                  Hard Worker