JAIN HAPPY SCHOOL
CLASS 11
CHAPTER-3
PYTHON FUNDAMENTAL
Q1. What is character set?
Ans: character set is a set of valid characters that a language can recognize. A character
represents :
• Letters ---- A-Z ,a-z
• Digits ------ 0-9
• Special Symbols ----- space + - * see page 44 and write other special symbol
• Whitespaces :see PPT
• Other characters: see PPT
Q2 What are tokens in python? How many types of tokens are allowed in python?
Ans: It is the smallest element of the Python program. All / any thing that we use in our
program is a part of Token. It is also known as lexical unit.
It consist of 5 main elements in it. These are
• Keyword: Words which are define in python eg: for,if , def , else, True,False, else,
while
• Identifier: These are the unique names that we provide to different programming
elements (such as variable, functions, class etc) which are created by us.
• Literals: These are the constant (fixed) values that do not change during the program
execution. Eg: strings, numeric, boolean
• Operators: eg: unary,binary,bitwise etc
• Punctuators: symbols lke #, [] , () ,{} , @ etc
Q3 How are keywords different from identifier?
Ans: book sumitaarora page no-75 solved problems q1
Q4 Explain the naming rules of identifiers.
Ans:
Q5: What are literals in python? How many types of literals are allowed in python?
Ans
Q6 Explain briefly numeric literal & explain three types with examples.
Ans: literal support three type of data:
a) Int(integer)-3,45,67,78
b) Float(decimal)-3.4,56.6,67.5
c) Complex number: (3+5j)
Q7. How are string-literals represented and implemented in python?
Ans: It is a collection of character type value which can consist of A – Z a – z 0 – 9 or any
special symbol
• It must be enclosed in ‘Single Quotes’ , “Double Quotes” or even ‘’’Triple Quotes’’’
• Without quotes python will not treat it as string
• Strings can be of two types:
i) Single Line String: Needs to be created in a single line and is enclosed in single or
double quotes
Example a=“Ram”
nm=“Hello everyone”
ii) Multi Line String:Can cover multiple lines and is enclosed in triple quotes
Example:
a = ‘’’Ram
Kumar ‘’’
address = ‘’’ 13 – B Delhi Road
Saharanpur ‘’’’
Q8 Which of these is not a legal numeric type in python?
a) Int b) float c) decimal
Ans: Decimal is not a legal numeric type in python
Q9 What is the error in following code:
X , Y =7?
Ans: The error is that the assignment of two variables is being done by providing just one
value. A TypeError will be raised.
Q10. Can nongraphic characters be used in python? how? Give examples to support your
answer?
Ans: Yes nongraphic characters can be used in python using a backslash.
Q11. Explain briefly escape characters in python.
Ans:
Q12.What are variables ?How are they important for a program.
Ans: Variable is a label that can used in process of program. it can contain numeric values,
character, string is called variable.
Variable play very important role in programming because they enable programmers to
write flexible programs. without variable we can not enter the data directly in the program.
Q13. Write a program to obtain three numbers and print their sum.
Ans:num1=int(input(“enter number1:”))
num2=int(input(“enter number2:”))
num3=int(input(“enter number3:”))
Sum=num1+num2+num3
Print(“three numbers are:”,num1,num2,num3)
Print(“Sum is :”,Sum)
Output: enter number 1:7
enter number 2:7
enter number 3:3
three numbers are: 7 7 3
Sum is: 17
Q14. How can you create multi-line strings in python?
Ans: page no-71 ,75 solved problem Q6
Q15. Identify the types of following literals?
23.789 23789 True ‘True’
“True” False “’False’”
Ans: page no-71,76 solved problem Q9
Q16. What is none literal in python?
Ans: page no-71,76 solved problem Q8
Q17. What factors guide the choice of identifiers in programs?
Ans: page no-71,75 solved problem Q5
Q18. Define Boolean literal.
Ans: Boolean literals represent only two values true or false. And in Java the
value of 1 is assumed as true and the value of 0 .
Q19. Write a program to assign two complex numbers in two variables and perform their
addition and display the result.
Ans: a= 3.4+2.4j
B= 1.4+2.4j
c= a+b
print(c )
4.8+4.8j
Q20. Write a program to obtain length and breadth of a rectangle and calculate its area.
Ans: book page no-71(old book)
Q21. define Punctuators.
Ans:
Q22. What is the difference between an expression and a statement in python?
Ans: page no-71 solved problem Q10(OLD BOOK) (Pls see new book solved problem)
Q23.Which of the following are syntactically correct strings? State Reasons.
a) “ This course is great !”
b) ‘She shouted “Hello!”very loudly.’
c) “Goodbye’
d) ‘This course is great1’
e) “Hello
f) “ l liked the movie ‘Bruce Almighty’ very much.”
Ans: page no-71 solved problem Q11(old book)
Q24. What is the error in following python program with one statement?
Print(“My name is”,name)
Ans page no-72 solved problem Q12
Q25.Write the corresponding python assignment statements:
a) Assign 10 to variable length and 20 to variable breadth
b) Assign the average of values of variables length and breadth to a variable sum.
Ans: page no-73 NCERT QUESTION (SUMITA ARORA)Q2
Q26. Write a program to find the average of 3 numbers.
Ans: a = int (input(" Please Enter the First Number: "))
b = int (input(" Please Enter the second number: "))
c = int (input(" Please Enter the third number: "))
average=(a+b+c)/3
print("The average of three numbers is ", average)
Output:
Please Enter the First Number: 3
Please Enter the second number: 5
Please Enter the third number: 1
The average of three numbers is 3
Q27. Explain briefly comments and its type.
Ans: These are the useful piece of text that we write remarks for our self in order to give
addition readable information about our Python Program.
• They are ignored by the Python Interpreter.
• In Python comments are of 2 Types. These are :
a) Single Line Comments : Created using # symbol at the beginning of the line.
# This is a Single Line Comment
b) Multi Line Comments : Created by enclosing the comments in ‘’’ Triple Quotation
marks ‘’’
c) ‘’’ This is a multi line Comment ’’’
Q28. Explain blank Lines and whitespace.
Ans: blank lines: Whenever you are creating a function after another function leave a blank
line between them to increase readability of code.
• Whitespace: You should always have whitespace around operators again for the sake
of increasing the readability of code.
Q29. 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
6. Comments