CBSE Computer Science Class 11 Python Fundamentals

Python Tokens & Variables Quiz | cbsecs.in

Python Tokens & Variables Quiz

Character Sets | Tokens | L-value & R-value | Comments

1. Which character set does Python use by default?
  • ASCII only
  • Unicode
  • EBCDIC
2. What are ‘Punctuators’ in Python?
  • Words with special meaning
  • Symbols used to organize sentence structure (e.g., [], {}, ,)
  • Variables that store numbers
3. In the statement X = 10, which is the ‘L-value’?
  • X
  • 10
  • =
4. Which symbol is used for writing a single-line comment in Python?
  • //
  • /*
  • #
5. What happens when you try to assign a value to an R-value, like 10 = X?
  • It works perfectly
  • SyntaxError: cannot assign to literal
  • It creates a variable named 10
6. A named memory location that stores data is called a:
  • Constant
  • Variable
  • Keyword
7. Multiline comments (docstrings) are often enclosed in:
  • Triple quotes (”’ or “””)
  • Square brackets []
  • Curly braces {}
8. Which of these is NOT a Python token?
  • Identifier
  • Operator
  • Memory Address
9. What is the value of a after: a = 5; b = a; a = a + 2?
  • 5
  • 7
  • 2
10. In Python, variables are created:
  • When they are declared without a value
  • The moment you first assign a value to them
  • Only at the start of the program
CERTIFICATE OF ACHIEVEMENT

This award is presented to

Student Name

for completing the Python Tokens & Variables Assessment

Score: 0 / 10

Elementary Concepts of Python

The fundamentals of Python include its syntax, data types, operators, control flow, functions, and data structures. These elements form the basic building blocks for writing programs, and Python’s straightforward design makes them relatively easy for beginners to learn.

Syntax and basic concepts

Python Identifiers Quiz | cbsecs.in

Python Identifiers Quiz

20 Questions: 10 Rules | 10 Examples

Part 1: Theoretical Rules

1. Which character set does Python recognize for its identifiers?
  • ASCII only
  • Unicode
  • EBCDIC
2. An identifier cannot start with which of the following?
  • An underscore (_)
  • A letter (A-Z or a-z)
  • A digit (0-9)
3. How does Python treat identifiers ‘Value’ and ‘value’?
  • As identical
  • As different (Case Sensitive)
  • Only ‘value’ is valid
4. Which of these symbols is allowed inside an identifier?
  • Hyphen (-)
  • Underscore (_)
  • Dollar Sign ($)
5. What is the limit on the length of a Python identifier?
  • 31 Characters
  • 255 Characters
  • Unlimited length
6. Can a ‘Keyword’ like ‘while’ be used as a variable name?
  • Yes, always
  • No, they are reserved
  • Yes, if in uppercase
7. Are spaces allowed inside a single identifier name?
  • No
  • Yes, if quoted
8. Which of these can be an identifier?
  • Variable names only
  • Variable, Function, and Class names
  • Literals
9. What category do symbols like [], {}, and () fall into?
  • Identifiers
  • Punctuators
  • Literals
10. Why is starting with a digit illegal?
  • It uses more RAM
  • To prevent confusion with numeric literals

Part 2: Examples & Validation

11. Which of these is a VALID identifier?
  • 2nd_var
  • _total_score
  • total-score
12. Identify the INVALID identifier:
  • True_Val
  • True
  • TRUE
13. Which of the following is invalid because of a punctuator?
  • roll_no
  • roll.no
  • rollNo
14. Is ‘____’ (multiple underscores) a valid identifier?
  • Yes
  • No
15. Identify the VALID identifier:
  • my$price
  • data_2
  • class
16. Which of these is invalid due to naming rules?
  • else
  • Else
  • ELSE
17. Which identifier is correctly formed?
  • student name
  • _student_name
  • student@name
18. Identify the valid identifier using digits:
  • 9lives
  • lives9
  • lives-9
19. Which of these can be used as a name?
  • yield
  • yield_value
20. What is the output of choosing ‘None’ as a variable name?
  • Success
  • SyntaxError
CERTIFICATE OF ACHIEVEMENT

This award is presented to

Student Name

for completing the Python Identifier Naming Assessment

Score: 0 / 20

Indentation: Python uses whitespace and indentation to define the scope of code blocks, unlike many languages that use braces ({}). Correct indentation is mandatory and critical for the program to function.

Comments: A hash symbol (#) denotes a single-line comment, which is text that the Python interpreter ignores. Multi-line comments can be created by using multiple hash symbols or with triple-quoted strings.

Input and Output: The print() function is used to display output, while the input() function prompts a user for text input from the console.

Variables and data types

Variables: Variables are names that act as references to values stored in memory. A value is assigned to a variable using the equal sign (=).

Dynamic typing: Python is dynamically typed, which means you do not need to declare a variable’s data type. The interpreter infers the type at runtime based on the value assigned.

Basic data types:

Integers (int): Whole numbers, like 10, -5, 42.

Floating-point numbers (float): Numbers with a decimal point, like 3.14, -0.5.

Strings (str): Sequences of characters, enclosed in single or double quotes, like “Hello World” or ‘Python’.

Booleans (bool): Represents truth values, either True or False.

Operators

Operators are special symbols that perform operations on variables and values.

Arithmetic operators: Perform mathematical calculations, such as + (addition), – (subtraction), * (multiplication), / (division), % (modulus), and ** (exponentiation).

Comparison operators: Compare two values and return a boolean result. Examples include == (equal to), != (not equal to), > (greater than), and < (less than).

Assignment operators: Assign values to variables, such as = (assignment) and += (add and assign).

Logical operators: Combine conditional statements. The main logical operators are and, or, and not.

Control flow

Control flow statements determine the order in which a program’s instructions are executed.

Conditional statements (if, elif, else): Allow code to execute different blocks of code based on whether specific conditions are True or False.

Loops (for, while): Enable a block of code to be executed repeatedly. A for loop iterates over a sequence, while a while loop continues as long as a certain condition is met.

break and continue: These statements alter the flow of a loop. break exits the loop entirely, while continue skips the rest of the current iteration and proceeds to the next.

Functions

A function is a reusable block of code that performs a specific task.

Defining a function: Functions are defined using the def keyword, followed by the function name and parentheses.

Arguments and parameters: Functions can accept data, called arguments, through parameters listed in the parentheses.

The return statement: This statement is used to exit a function and pass a value back to the caller.

Data structures

Python has several built-in data structures for storing and organizing data efficiently.

Lists: Ordered, mutable collections of items, created with square brackets ([]).

Tuples: Ordered, immutable collections of items, created with parentheses (()).

Sets: Unordered collections of unique items, created with curly braces ({}).

Dictionaries: Unordered collections that store data as key-value pairs, created with curly braces ({}).

error: Content is protected !!