CH - 6 Python Fundamentals
CH - 6 Python Fundamentals
1. Special meaning words of pythons, fixed for specific functionality are called?
Ans: Key words.
2. Names given to different parts of a python program are?
Ans: Identifiers.
3. Data item having fixed value are called
Ans: Literals.
4. What of the following is/are correct ways of creating strings?
Ans: name = ‘Jiya’ name = “Jiya”
5. Which of the following are key words?
Ans: print()
6. Which of the following are valid identifiers?
Ans; _myname, myname
7. Which of the following are literals?
Ans: “Radha”, 24.5
8. Escape sequence are treated as …………………..
Ans: Characters
9. Which of the following is an escape sequence for a tab character?
Ans: \t
10. Which of the following is an escape sequence for a new line character?
Ans: \n
11. Which of the following is not a legal integer type value in python?
Ans: Roman
12. Which of the following symbols are not legal in an octal value?
Ans: 8, 9
13. Value 17.25 is equivalent to …………
Ans: 0.1725E+2
14. Value 0.000615 is equivalent to ………..
Ans: 0.615E
15. Which of the following is/are expressions?
Ans: a+b-5
16. The line beginning with a certain character, and which are ignored by a compiler and not executed are called…
Ans: Comments
17. Which of the following can be used to create comments?
Ans: #
18. Which of the following functions print output to the console?
Ans: print()
19. Select the reserved keyword in python….
Ans: print, Import, else
20. The input() return the value as ……….. type.
Ans: String
21. To convert the read value through input() into integer type, …………. () is used.
Ans: int
22. To convert the read value through input() into a floating point number, …………… () is used.
Ans: float
23. To print a line a text without ending it with a newline, …………. Argument is used with print()
Ans: end
24. The default separator character of print() …………. Argument is used.
Ans: space
25. To give a different separator with print() …………. Arguments is used.
Ans: sep
6. How are strings is not a legal type in python? a . int b. float c. decimal
Ans: The legal types in Python are int, float, str. decimal is not a standard built-in type but can be accessed
through the decimal module.
7. Which arguments for print() would you set for:
i. Changing the default separator? ii. Printing the following line in current line?
Ans: print() Arguments:
i. sep argument (e.g., print("a", "b", sep="-"))
ii. end argument for printing in the same line (e.g., print("Hello", end=" "))
8. What are operator? What is function? Give examples of some unary or binary operators.
Ans: Operators perform operations on variables (e.g., +, -). Functions are blocks of code that perform a task.
Unary operators work on one operand (e.g., -x), and binary operators require two operands (e.g., x + y).
9. What is an expression and statements?
Ans: An expression produces a value (e.g., 5 + 2), while a statement performs an action (e.g., x = 5 + 2).
10. What all components can a python program contain?
Ans: Python programs can contain expressions, statements, functions, classes, modules, and packages.
11. What do you understand by block/code block/suite in python?
Ans: A block or code suite is a group of statements that execute as a unit, usually defined by indentation in
Python.
12. What is the role of indentation in python?
Ans: Indentation defines the structure and grouping of blocks in Python, making it essential for indicating loops,
functions, and conditionals.
13. What are variables? How are they important for a program.
Ans: Variables are named locations in memory to store values. They help in holding data that can be manipulated
during program execution.
14. What do you understand by a undefined variables in python?
Ans: Undefined variables are variables that have not been assigned a value before they are used, leading to errors.
15. What is dynamic typing features of python?
Ans: Python allows dynamic typing, meaning variables can change types at runtime (e.g., x = 5, x = "hello").
16. What would the following code do. X = Y = 7 ?
Ans: X = Y = 7: Both X and Y will be assigned the value 7.
17. What is the error in following code. X , Y = 7 ?
Ans: This causes a Value Error because there are two variables but only one value to assign.
18. Following variables definition is creating problems X = 0281, find reasons.
Ans: Python does not allow leading zeros in integers unless it’s a valid octal (base-8) number. The correct form
would be X = 281.
19. “Comments are useful and easy way to enhance readability and understandability of a program”. Elaborate with
examples.
Ans: Comments, written with #, help explain the code and make it more understandable. For example:
# This is a comment explaining the next line
print("Hello, World!")