Questions and Answers Python Fundamentals Class 11 Computer Science and Informatics Practices

Solved Assignment – Python Fundamentals

Theory Questions

Q – 1 What are the important parts of a program?
Answer: A python program has the following important parts:
    1. Function Header
    2. Statements
    3. Expressions
    4. Tokens
    5. Function call

Q – 2 Identfy variable or identifier, operator and value in a = 5 statement.

Answer: In a = 5, statement a is a variable or identifier, = is operator and 5  is value.
Q – 3 What do you mean by address, value and data type? How to print the address, value, and data type of a variable in a python program?
Q – 6 What is a variable?
Q – 7 Explain variable assignment in detail with multiple assignment statements.
Q – 8 How to use input() function and print() function? Explain n detail.  
Read Python documentation for inbuilt python function.
Q – 9 What is typecasting? Explain with example.

Application-based Questions

Q – 1 Which of the following are invalid identifiers? 
mynum, 1tab, stu roll no, for1, for, While, while
Ans.: 1tab → Starts with a number, stu roll no → space is given in the variable name, for and while are keywords
Q – 2 Find errors in the following code:
i) stu_marks = 90
print(Students Score stu_marks)
Ans.: There is error in line 2. The print() function accepts only variable without function if the user needs to print any custom message, the message text should be enclosed in double-quotes. So correct statement is anyone these:
print(“Students Score:”, stu_marks)
ii) a = 30, b = 40
Ans.: There is an error in line 1. Python doesn’t allow to assign multiple variables like this. If its required it can be done either one of these ways:
a,b = 30, 40
a = 30
b = 40
There is an error in line 2 as well. To separate values of the variable in print, user can use, (comma) not a semicolon, hence the correct code is like this:
iii) stu_name (input=”Enter name of student:”)
      print(“Student Name:”,Stu_name)
Ans.: There is error in line 1. When input() function is used in the expression, in must come after =. Here the correction is like this:
stu_name = input(“Enter name of student:”)
iv)  x, y = 30, 7
      z = (int) x/y
Ans.: There is an error in the typecasting statement. In python, the statement where type casting is required is written as a parameter in specific data type function. 
Q – 3 Find the output:
(i) a = 3
(ii) a = 5
      b = a
      c = b – 3
Ouptut: 5 5 2
(iii) cname = “Subodh”
       print(“Customer Name & Bill:”,cname+1500)
Output:No output due to Error, cname is string and bill_amount is integer
(iv) a = 55
      b = a + 4
      a = 30, b + 2
      print(b, a)
Ouptut: 59 (30,61) . Initially the value of a is 55, the value of b is 55 + 4 = 59, in third line the value of a is gain changed as mentions 30, 59 + 2= (30, 61). So in print function first value of b is printed, then a is printed Hence ouptut is 59 (30,61)
(v) a, b  = 10, 30
      a, b, a = b, b + 3, a – 5
     print( a, b) 
Ouptut: The value of a and b is 10 and 30 respectively. After that, in next line the value of b is assigned to a i.e 30 then b + 3 = 30 + 3 = 33 assigned to b and finally a -5 = 10 – 5 = 5 assigned to a. So output will be 5 33. 
(vi) a, b = 10 , 5
Ouptut: 15
             <class ‘NoneType’>. As print() function is nested in the code gives None output for the outer print() function. type() function returns the final data type of the value. 

Comment Your Views

%d bloggers like this: