Python Fundamentals Practice Questions

Table of Contents
- Python Fundamentals Practice Questions – Test 1
- Python Fundamentals Practice Questions – Test 2
- Python Fundamentals Practice Questions – Test 3
- Python Fundamentals Practice Questions – Test 4
- Python Fundamentals Practice Questions – Test 5
- Python Fundamentals Practice Questions – Test 6
- Python Fundamentals Practice Questions – Test 7
- Python Fundamentals Practice Questions – Test 8
- Python Fundamentals Practice Questions – Test 9
- Python Fundamentals Practice Questions – Test 10
Python Fundamentals Practice Questions – Test 1
Q. Name two modes of Python.
Q2. Write Full Form of IDLE
Q3. Interface mode of python is also known as _______________.
Q4. In which mode we get result immediately after executing the command?
Q5. Write the output of the following.
a. >>> x = 5
  >>> y = 7
  >>> print(x + y )
b. >>> print(2 **5)
a. 12 b. 32
Q6. Write one drawback of interactive mode.
Q7. Ananya purchased 5 pencils and 2 erasers at the cost of Rs 7 and Rs 5 respectively. Write the program to calculate & display the total amount paid by ananya.
penc = 7
er = 5
totcost = penc * 5 + 2 * er
print("Total cost paid by Ananya is",totcost)
Q8. What do you mean by comments in Python?
Q9. Which symbols are used for single line comments and multiple line comments?
Q10. What do you mean by variable?
Â
Python Fundamentals Practice Questions – Test 2
Q1. What is the purpose of creating variables?
Q2. Write code to find the address of variable.
>>>id(x)
Q3. What do you mean by data type?
Q4. Write three numeric data type in python.
Q5. Name three sequential data types in python.
Q6. >>> x = 200
>>> y = 10.5
Write the data type of variable x and y.
Ans. a. Integer
b. Floating point
Q7. Data type of variable is according to the value it holds.(T/F)
Q8. Which data type store the combination of real and imaginary numbers?
Q9. Write the output of the following:
>>> 4.7e7
>>> 3.9e2
47000000
390
Q10. Which data type return value True or False?
Python Fundamentals Practice Questions – Test 3
Q1. Write the output of the following :
- >>> (75 > 2 **5)
- >>> (25 != 5 *2)
1. True 2. True
Q2. Which operator can be changed in above part (2) so that it returns True?
Q3. Dictionary is enclosed in ___________ brackets.
Q4. What do you mean by keywords in python?
Q5. Keywords can be used as variable names (T/F)
Q6. Write the code to display all keywords in python.
Q7. Write two keywords which start with capital letters.
Q8. Write the output of the following
>>> str = "Informatics" >>>str[3] = 'e' >>> print(str)
Q9. Write the output of the following:
>>> a = [1,2,3] >>>a[0] = 6 >>>print(a)
Q10. Name three types of operators in python.
Python Fundamentals Practice Questions – Test 4
Q 1. What do you mean by Escape sequence?Ans The sequence of characters after backslash is called escape sequence.Q 2. Write the output of the following >>> x = 2 + 5j >>> print(x.real, x.imag)Ans. 2.0 5.0Q 3. What is None data type?Ans. This data type is used to define null value or no value. for example m = none, Now the variable 'm' is not pointing to any value, instead it is pointing to none.Q 4. Write the output of the following >>> v1 = 10 >>> v2 = None >>> v1 >>> v2 >>>print(v2)Ans. 10 NoneQ 5. What is the purpose of type() function?Ans. This function tell us about the data type of a variable. for example a = 10 print(type(a)) OUTPUT : <class 'int'>Q 6. Write the output of the following. >>> type(10) >>>type('10') >>>type(10.0) >>>type(True) >>>type('False')Ans. <class 'int'> <class 'str'> <class 'float'> <class 'bool'> <class 'str'>Q 7. Which function is used to find the data type of variable?Ans. type() functionQ 8. Write the output of the following >>> a = "hello" >>> b = 10 >>> c = 9.8 >>> d = 7 + 3.6j >>> print(a) >>> print(b) >>> print(c) >>> print(d)Ans hello 10 9.8 7 + 3.6jQ9. Identify the variable name, variable type, value and operator used in the following statement. >>> x = 9Ans. variable name -- x variable type -- integer value -- 9 operator -- =Q 10. What do you mean by assignment operator?Ans. An operator which is used to assign a value to a variable is called assignment operator. Symbol of assignment operator is '=', for example c = 10, value 10 will be assigned to variable 'c'
Python Fundamentals Practice Questions Test 5
Q1. Write the output of the following : >>> x = 8 >>> x = 5 >>> print (x + x)Ans. 10Q2. Is the following statement correct? >>> a, b, c = 2 , 3 , 'Amit'Ans. yesQ3. Identify the invalid variable names from the following and specify the reason also. a) m_n b) unit_day c) 24Apple d) #sum e) for f) s nameAns. 24apple : Variable can not start with number #sum : Variables can not start from special character. for : Keyword can not be used as variable s name : Spaces are not allowed in variable namesQ4. What are keywords?Ans. Keywords are reserved words which have special meanings to pythonQ5. Keywords can be used as variable names (T/F)Ans. FalseQ6. Write the code to display all the keywords available in python.Ans. import keyword print(keyword.kwlist)Q7. What do you mean by expression?Ans. A combination of operators and operands is called expression. like - a + b * cQ8. Write the python expressions equivalent to the following algebraic/arithmetic expressions z = u/5 z = 9ab + d z = x+4/j + 7Ans. 1. z = u/5 2. z = 9*a*b + d 3. z = x + 4/j + 7Q9. What are operators? Name three types of operators.Ans. Operators are special symbols that perform a specific task (arithmetic or logical operations) Three types of operators are 1. Logical Operators 2. Relational Operator 3. Mathematical OperatorQ10. >>> 7 % 10 will return ____________________Ans 7
Python Fundamentals practice Questions Test 6
Q1. Write the output of the following:
print("hello * 5")
print("hello" * 5)
print("***" * 5)
print("Hello", "how", "R", "U")
print("Hello" + "how" + "R" + "U")
print("Amit" + "Sethi")
print(23 + 9)
print ("7 + 9")
print(7/6)
print(7//6)
print(8 % 2)
print(3 % 7)
print(4 ** 3)
print (7 * 5)
print (8 - 16 )
Ans
hello * 5
hellohellohellohellohello
Hello how R U
HellohowRU
AmitSethi
32
7 + 9
1.1666666666666667
1
0
3
64
35
-8
Q2. What do you mean by string concatenation? Give example
Ans. String Concatenation means joining the strings. for example
>>>s = "Amit" + "Sethi"
>>> print(s)
Output is :
AmitSethi
Q3. What do you mean by binary and unary operators? Give one example of each.
Ans. Binary operators work on two or more operands like Division (/), Multiplication (*).
2 / 3
4 * 3
Unary operators work only on one operand like Subtraction (-)
-9
-7
Q4. Evaluate the following expressions
23 + 4 **2
9 * 3 - 8 + 6
7%2 + 7//2
67 + 3%3
12 % 4 + 6 + 4 // 3
Ans
39
25
4
67
7
Q5. Write the name and purpose of the following operators.
//
%
**
Ans.
// : Name of Operator is Floor Division . It is used to find the integer part of the quotient when one number is divided by other
% : Name is Modulus or Remainder Operator . It is used to find the remainder when one number is divided by other
** : Name is Exponent. It is used to find the power of a number like 2**3 will give result 8.
Python Fundamentals Practice Questions Test 7
Q1. Out of relational and arithmetic operators which have higher precedence?Ans. Arithmetic OperatorsQ2. Write the output of the following >>>35 < 6 >>>5 > 2**2 >>>7 != 3.5 *2 >>>7 == 3.5 ** 2 >>> "Anil" > "Anita"Ans. False True False True FalseQ3. What do you mean by shorthand operator?Ans. A combination of assignment and binary operator is called shorthand operator. for example x=x+2 can be written with shorthand operator as x +=2Q4. Write the output of the following if x = 8. >>> x + = 8 >>> x - = 8 >>> x * = 8 >>> x ** = 2 >>> x % = 8 >>>x / = 8 >>> x // = 8Ans. 16 0 64 64 0 1.0 1Q5. What is the purpose of input function?Ans. input() function is used to take/accept data from the user.Q6. Write a program to accept name from the user and display "Hello <name>"Ans. name=input("Enter any name") print("Hello",name)Q7. Write a program to accept the first name and last name from user and display the full name.Ans. fname=input("Enter your first name") lname=input("Enter your last name") print("Complete name is",fname , lname)Q8. Write a program to accept two numbers from the user and display their sum and product.Ans. n1=int(input("Enter first number")) n2=int(input("Enter second number")) print("Sum is ",n1+n2) print("Product is ", n1*n2)
Python Fundamentals Practice Questions Test 8
Q1. What is the difference between eval() and int() function?Ans. eval( ) function return error on passing integer argument while int( ) function does not return error. for example : print(eval(12)) returns error print(int(12)) returns 12Q2. What do you mean by function?Ans. A set of statement in a program which perform a specific function is called function.Q3.Write the output of the following >>>eval('15') >>>eval("6") >>>eval(7) >>>eval("5 + 8 * 6)Ans. 15 6 Error 53Q4. def command is used to define a function or to call a function.Ans. def is used to define a functionQ5. Write a user defined function to find the area of rectangle.Ans. def area_rect( ): len=int(input("Enter length of rectangle)) br=int(input("Enter breadth of rectangle)) area=len*br print("Area of rectangle is " , area)Q6. Write a user defined function to print "Python Fundamentals" five times.Ans. def hello( ): print("Python Fundamentals") print("Python Fundamentals") print("Python Fundamentals") print("Python Fundamentals") print("Python Fundamentals")Q7. Write a user defined function to find the volume of cube.Ans. def area_cube( ): side = int(input("Enter side of cube")) print("Volume of cube is " , side*side*side)Q8. All statements in python are terminated by semicolon.(T/F)Ans. FalseQ9. How many spaces are there in one indentation level?Ans. 4Q10. In python one line can be of maximum ___________ characters.Ans. 79
Python Fundamentals Practice Questions Test 9
Q1. What do you mean by comment in python?Ans. Non executable lines in python are called comment. Comment in python begin with symbol '#'Q2. A comment in python starts with __________ symbol.Ans. #Q3. Is python a case sensitive?Ans. YesQ4. What do you mean by dynamic typing?Ans. When we do not declare the type of variable before assigning a value is called dynamic typing.Q5. Define the following term Token Keyword String Operators int() function type() functionAns. Smallest unit/element of python program is called token. Those words which have special meaning for the interpreter of python are called keywords. Sequence of characters which are enclosed in single or double quotes is called string An Operator is a symbol or a word that perform a specific operation(Mathematical, Logical, Comparison) on operands and return the result. int() : This function converts the String to integer. for example print(int("123")) will print 123 as integer.Q6. Precision of _________ digits in floating point numbers in python.Ans. 15Q7. input() function always return a value of __________ type.Ans. StringQ8. Write the output of the following >>> x , y = 3, 5 >>>x, y = y, x + 6 >>> print(x,y)Ans. 5 9Q9. What is the extension of python file?Ans. .pyQ10. Find the error in the following code def sub(n1, n2) res = n1 - n2 return resAns. Correct code is def sub(n1,n2): res = n1 - n2 return res
Python Fundamentals Practice Questions Test 10
Q1. Write a program to accept radius of circle and display it's area and circumference.Ans. import math r=int(input("Enter radius of circle")) print("Area of Circle is ",math.pi*r*r) print("Circumference of Circle is ",2*math.pi*r)Q2. Write a program to find the average marks of five subjects. (Accept marks from user)Ans m1=int(input("Enter marks of Subject-1 :")) m2=int(input("Enter marks of Subject-2 :")) m3=int(input("Enter marks of Subject-3 :")) m4=int(input("Enter marks of Subject-4 :")) m5=int(input("Enter marks of Subject-5 :")) s = m1+m2+m3+m4+m5 print("Average marks of five subjects ",s/5)Q3. Write a program to find the area of right angle triangle. (Accept base and height from user)Ans. b=int(input("Enter the base of triangle :")) h=int(input("Enter the height of triangle :")) print("Area of triangle is :",1/2*b*h)Q4. Write a program to print the following pattern without loop. * * * * * * * * * *Ans. for i in range(1,5): for j in range(i): print("*",end=" ") print()Q5. Write a program to find the volume of sphere.(Accept radius from the user)Ans. import math r=int(input("Enter the radius of sphere")) print("Volume of sphere is ",4/3*math.pi*r*r*r)Q6. Find errors a = input(Enter your name) b = input("Enter any number")Ans. Correct statements are a=input("Enter your name") b=int(input("Enter any number"))Q7. Find errors: a = input("Enter your name" Print(Your name is, a)Ans. Correct code is : a = input("Enter your name") print("Your name is: ", a)Q8. Write the output of the following a, b = 2, 6 a, b, b = a+b, 2, 3 print(a,b)Ans. 8 3Q9. Write the output of the following. a = 5 b = "Amit" print(a + b)Ans. It will show ERRORQ10. Write the output of the following. a =3 b =4 print(a + b%2 + a**2)Ans.12
Class 12 Computer Science Sample Paper 2020-2021.
Class 12 Computer Science Sample Paper Marking Scheme
Class 12 Computer Science Test Series







