0% found this document useful (0 votes)
10 views

CH - 6 Python Fundamentals

Uploaded by

shobhati8349
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

CH - 6 Python Fundamentals

Uploaded by

shobhati8349
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

 Multiple Choice Questions

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

 Fill in the blanks:


1. Keyboard is a reserved key word carrying special meaning and purpose.
2. Identifier are the user defined names for different parts of a program.
3. Literals are the fixed values.
4. Operator are the symbols that triggers some computation or action.
5. An expression is a legal combination of symbols that represents a value.
6. Non, executable additional lines added to a program, are known as Comments.
7. In python, the comments begin with # character.
8. Python is a case sensitive language.
9. The print() prints the value of a variable/expressions.
10. The input() function gets the input from the user.
11. The input() functions return the read value as of string type.
12. To convert an input()’s value to an integer type, into int function is used.
13. To convert an input()’s value in floating point type, float() Function is used.
14. String can be created with single quotes, double quotes and triple quotes.
 True/ False Questions.
1. Keyword can be used as identifiers names. [F]
2. The identifiers in python can begin with an underscore. [T]
3. 0128 is a legal literals value in python. [F]
4. 0x12EFG is a legal literals value in python. [F]
5. 0123 is a legal literal value in python. [T]
6. Variable once assigned a value can be given any other value. [T]
7. Variable are created [T]
8. Python variable support dynamic typing. [T]
9. You can rename a key word. [F]
10. String value in python can be single line strings, and multi-line strings. [T]
11. A variable can contain values of different types at different times. [T]
12. Expression contains values\variables along with operators. [T]
 Short answer Questions/ Conceputual questions.
1. What are tokens in python? How many types of tokens are allowed in python?
Ans: Tokens are the smallest elements in a Python program. The five types of tokens in Python are keywords,
identifiers, literals, operators, and punctuators.
2. How are key words different from identifiers?
Ans: Keywords are reserved words with predefined meanings (e.g., if, for), whereas identifiers are names used to
identify variables, functions, classes, etc., and are defined by the user.
3. What are literals in python? How many types of literals are allowed in python?
Ans: Literals are fixed values assigned to variables. Python allows several types of literals: string, numeric
(integer, float, complex), Boolean, and special literals like None.
4. Can nongraphic characters must be used in python? How? Give examples to support your answer.
Ans: Non-graphic characters (such as escape sequences like \n for newline, \t for tab) can be used in Python to
represent actions within strings.
5. How are floating constant represented in python? Give examples to support your answer.
Ans: Floating constants are represented with decimal points (e.g., 3.14, 0.001) or in scientific notation (e.g.,
1.23e4).

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!")

You might also like