USN 1 BM
B.M.S. COLLEGE OF ENGINEERING, BENGALURU-19
                                  (Autonomous Institute, Affiliated to VTU)
                             CONTINUOUS INTERNAL EVALUATION (TEST-1)
Course Code: 22CS2PLPYP            Course Title: Introduction to Python Programing
Semester: |                           Maximum Marks: 40 Date: 08-07-2023
Faculty Handling the Course: Prof. RM,Prof. RK, Dr. GSK, Dr. DK, Dr. CRD, Dr. RS, Prof. LN
  Instructions:
                     Common paper to all the branches in physics &PLC Cycle
        1. First Five Questions are compulsory.
        2. Internal choice is provided between Question 6 and 7
        3. Missing Data may be suitability assumed
                                                                                                  Mark       CO       PO
                                                                                                  S
   1.   List any 2 rules to frame variable names. ldentify whether the following are                         2        2
        valid or invalid variable names. Justify your answer if they are
             a. 78Python            b. first name
                                                                         invalid.
                                                       c. false
             Identify errors in the below given code fragments. Justify why python                06
              throws an error and write the output for the corrected python code.
                       X=100
                 a     y=300
                       1f x>y                            b
                           X-y=X                              X<y:
                        elsif:                               icx i range (x, y, 10) :
                           print (y)                             printf(i)
                                                             x=X+20
                                                             print (z)
        3      Illustrate the following concepts with suitable examples                               06
                     a) Heterogeneous Lists                    b) Mutable lists
                        Traversal                                                       c) List
        4       a) With a suitable example   illustrate the syntax and working of while loop.          4+3        2
                 b) Analyze the program given below and write the output.
                         tor i in [1,2,3,4,5]:
                                y=0
                                for        j in   range (i) :
                                    y=y+j
                                if yB2:
                                    Continue
                                print (y)
        5.       Given a line of text entered by the uscr, write a python
                 frequency of each vowel letter in it.                    program to count the 06
                 For example, if the input line is "Hello, how are
                 follows:
                                                                   you?", the output must be as
                 a' is repeated I times
                 'e' is repeated 2 times
                 "i isrepeated 0 times
                  'o' is repeated 3times
                                                                        USN 1 BM
       'u' is repcated I times
                                                                                       10
6.     Consider the below scenario: There are 5 users for whom electricity bill has
       to be generated based on the units consumed per month. Every user will be
       chargeda meter charge of Rs.250. The bill is generated based on the below
       categories of units consumed by the user:
       First 100 units are charged as Rs.5 per unit.
       For the next 100 units, Rs. 10 per unit.
       For Units exceeding 200, Rs. 15 per unit.                     number of
       Write a python program to read the user name. Bill Id and the
       units consumed. Calculate the total bill amount for each user.
                                          OR
                                                                                       10   3   3
7.    Consider the following scenario: John is a travel enthusiast. He loves to
       travel different places every month. This month, he has a plan to travel to 5
      different places. Write a program to input the name of the place and the
      amount required to visit that place from the user. Compute the total required
      travel amount. His bank offers him travel discounts as follows:
      If the total amount is between 10000 to 20000. 7% discount.
      Ifthe total amount is between 20000 to 25000, 12%discount.
      Ifthe total amount is between 25000 to 30000, 17% discount.
     If the total amount is above 30000, 20% discount.
     Find the net amount spent by John.