Monday, 22 April 2024

2. PRINT ANY TABLE

 

If You Want Creat A Table Of Any Number Like This (Table Of 5 Or 3 Or 9) You Can Run A Pythone Code And Make Is Table You Choice Like (Table Of 5 From 1 To 10 Or 1 To 20 Or 1 To 30).

SO RUN A CODE IN PYTHONE CODE RUNNER OR VISIUAL CODE STUDIO:

while True:
  a = input("please enter number and you will get a Table: ")
  print(f'Multipication Table of {a} is :')
  for i in range(1, 11):
   print(f"{int(a)} x {i} = {int(a)*i}")


while True:

      a = int(input("Enter a number: "))

      for i in range(11):

       print(a, "x", i, "=", a * i)

      choice= input("do you want perform calculatore again?(y/n): ")

      if choice != "y":

        break


NOTE :


while True:   basically he is a loop to used again program  run automatically function.

a = int(input("Enter a number: "))  basically he is used for user choice input for example if user enter a 5 so 5 table creat and when user is enter 3 so 3 table is creat.

 for i in range(11): he is a for loop that will automatically creat a table in a sequence like this . for example user can creat a table of 3 so.

3 x 1 = 3

3 x 2 = 6

3 x 3 = 9

means sequence vise table creat. and range(11) means table of 3 creat from 1 to 10. when range is (21)  so table creat 1 to 20.

         

  print(a, "x", i, "=", a * i)



    

No comments:

Post a Comment

MAKE A CALANDER

  # 1.  convert calander year and month. your choice month or year , print while True :   import calendar   year = int ( input ( "P...