Page 87 - Code & Click - 6
P. 87

D.  Answer the following questions.

                1.  What are the main features of Python programming language?
                2.  What is the difference between Script and Interactive mode?

                3.  Write the rules to follow for naming variables in Python.
                4.  What is the use of print( ) function in Python? How can you use the print( ) function to display
                    multiple values?


              Mind Stretching
              1.  Identify the correct statements in Python among the statements given below:         Logical Thinking
                  (a) print(This is a Python statement)
                  (b) Count = print(“Enter a number :”)
                  (c) print(“My name is”, Name)
              2.  Parag had created a program in Python. When he tried to execute it, Python reported errors
                 in his code. Observe the code given below and underline the errors in it. Also write the correct
                 code.                                                                            Computational Skills
                    # This is a test program
                    print(“Enter a number : )
                    num1 = input( )
                    print(“Enter another number : ”)
                    num2 = input( )
                    print(“The sum of the numbers is :” Num1 + num2)

              3.  Vaani had learnt about Python commands in class. She wanted to try the commands and
                 practice them. Which mode of working in Python would suit her purpose?              Logical Thinking

                                                                                                  Computational Skills
             Lab Work

             A.  Type the following commands at the Python prompt and write the output obtained.
                 (a)  >>> print(“I am learning Python”)
                 (b)  >>> print(40 * 30 + 60/3)
                 (c)  >>> 45 / 15 – 10 * 20
                 (d)  >>> Name = “Aditya”
                    >>> Age = 20
                    >>> print(“Hello”, Name, “, you are”, Age, “years old.”)
             B.  Write code for the following programs in Python.
                 (a)  Accept two numbers from the user in two variables named ‘Number1’ and ‘Number2’. Display the
                    sum, difference, product, and quotient of the two numbers.
                    (Hint: Use the operators +, –, *, and / for the four operations)
                (b)  Accept the name, class, and marks in four subjects from the user in appropriately named variables.
                    Display a welcome message with the name and class of the user. Also, display the sum and average
                    of the marks entered by the user.






                                                                                                                 85
   82   83   84   85   86   87   88   89   90   91   92