Page 105 - TrackpadV5.1_class8
P. 105

On running the above program, we get the following output:  Program 14: To create a number pattern using for loop

 Output              Program14.py

 Enter the temperature in Celsius: 15  File  Edit  Format  Run  Options  Window  Help
 It's cool outside.
                  #Program to create number pattern using for loop


 Program 13: To create a ticket vending simulation. If the age of a person lies between 10 to 20   for i in range(1,5):
 years, the price of the ticket will be Rs. 200. If the age of a person lies between 20 to 60 years, the       print('3' * i)
 price of the ticket will be Rs. 350. If the age of a person is greater than 60 years then the price of
 the ticket will be Rs. 300.
                 On running the above program, we get the following output:

 Program13.py
                     Output
 File  Edit  Format  Run  Options  Window  Help
                  3
 # Ticket Vending Machine  33
 # Price of ticket is Rs. 200 is age is between 10 to 20.  333
                  3333
 # Price of ticket is Rs. 350 is age is between 20 to 60.
 # Price of ticket is Rs. 300 is age is greater than 60.

 age = int(input("Enter your age: "))  Program 15: To print the pattern of stars in decreasing order in the form of triangle.

                     Program15.py
 if (age>10 and age<20):
     print("The price of the ticket is Rs. 200.")  File  Edit  Format  Run  Options  Window  Help
 elif (age>20 and age<60):
                  #Program to create star pattern
     print("The price of the ticket is Rs. 350.")
 elif (age>60):
                  for i in range(10, 0, -1):
     print("Ihe price of the ticket is Rs. 300.")      print("*"*i)
 else:
     print("No need of ticket.")
                 On running the above program, we get the following output:

 On running the above program, we get the following output:  Output

                  **********
 Output
                  *********
 Enter your age: 25  ********
 The price of the ticket is Rs. 350.  *******
                  ******
                  *****
                  ****
                  ***
                  **
 Imagine, you possess the power of jump statement, allowing you to leap to any   *
 part of the universe. Where would you jump to and what quests or missions
 would you undertake in each dimension?







                                                                                        Control Structures in Python  103
   100   101   102   103   104   105   106   107   108   109   110