Page 434 - ComputerScience_Class_11
P. 434

D.  Higher Order Thinking Skills (HOTS)
                  1.  A software company develops a Python application on Windows. Later, the client wants to run the same application on Linux
                    without changing the code. Explain how Python’s portability feature helps in this situation.
                Ans.  Python is a portable language, so a program written on Windows can run on Linux without changing the code. As long as the
                    Python interpreter is installed on the Linux system, the same program can be executed easily.
                  2.  A student is writing a Python program and accidentally uses the word for as a variable name. When he runs the program, it
                    shows an error. Explain why Python does not allow this and how keywords affect the execution of a program.
                Ans.  Python does not allow using for as a variable name because it is a keyword. Keywords like if, while and for have special
                    meanings in Python and using them as variable names causes a SyntaxError, stopping the program.

              E.  Assertion and reasoning questions.
                    The following questions consist of two statements - Assertion (A) and Reason (R). Answer these questions by selecting the appropriate
                  option given below:
                  a.  Both A and R are true and R is the correct explanation of A.
                  b.  Both A and R are true but R is not the correct explanation of A.
                  c.  A is true but R is false.
                  d.  A is false but R is true.
                  1.  Assertion (A): A programming language character set includes letters, digits, special symbols and whitespace characters.
                    Reason (R): These characters are used to write and structure programs in Python.
                Ans.  a.  Both A and R are true and R is the correct explanation of A.
                  2.  Assertion (A): Scalability means the ability of an application to grow in terms of performance and data handling.
                     Reason (R): Scalability refers only to increasing the size of the user interface of an application.
                Ans.  c.  A is true but R is false.
                  3.  Assertion (A): Python users cannot get help online when they face errors.
                    Reason (R): Websites like Stack Overflow and GitHub provide solutions shared by other users.
                Ans.  d.  A is false but R is true.

              F.  Case study-based questions.
                    A student installed Python on his computer and started learning programming using IDLE. He wrote a small program to store his
                  name and marks in variables and used arithmetic operators to calculate the two values. While practicing, he accidentally used a
                  keyword as a variable name and received an error message. His teacher explained the rules for naming variables and told him that
                  Python executes code line by line using an interpreter.
                  Based on the given case, answer the following questions:
                  1.  Which IDE did the student use to write the program?
                Ans.  The student used IDLE (Integrated Development and Learning Environment) to write the program.
                  2.  Why did the program show an error when he used a keyword as a variable name?
                Ans.  The program showed an error because keywords are reserved words in Python with special meanings. They cannot be used as
                    variable names.
                  3.  What are arithmetic operators used for?
                Ans.  Arithmetic operators are used to perform mathematical calculations such as addition (+), subtraction (−), multiplication (*) and
                    division (/).
                  4.  How does Python execute code?
                Ans.  Python executes code line by line using an interpreter, which reads and runs each statement one at a time.

              G.  Identify the error in the given codes and rewrite the correct code:
                  1.  radius = 5
                    area = 3.14 * radius * radius
                    print("The area of the circle is: " area)

                Ans.  radius = 5
                    area = 3.14 * radius * radius
                    print("The area of the circle is: " ,area)


                  432  Touchpad Computer Science (Ver. 3.0)-XI
   429   430   431   432   433   434   435   436   437   438   439