0% found this document useful (0 votes)
7 views3 pages

Class 7 Python

The document is a tech assessment for Class VII students on the basics of Python, covering topics such as comments, keywords, data types, and operators. It includes multiple-choice questions, fill-in-the-blanks, true/false statements, and definitions of key concepts. Additionally, it features short and long answer questions that explain the use of variables, relational operators, and the significance of comments in Python programming.

Uploaded by

cvma.cbseschool
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Class 7 Python

The document is a tech assessment for Class VII students on the basics of Python, covering topics such as comments, keywords, data types, and operators. It includes multiple-choice questions, fill-in-the-blanks, true/false statements, and definitions of key concepts. Additionally, it features short and long answer questions that explain the use of variables, relational operators, and the significance of comments in Python programming.

Uploaded by

cvma.cbseschool
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Basics of Python

Class VII
Tech Assessment

A. Tick ( ) the correct option.


1. Which of the following symbol is used to insert a comment in a program in Python?
Answer: (a) #
2. Keywords must be written in ___________ case except 'True', 'False and None.
Answer: (b) Lower
3. Which of the following function is used to convert a string into a floating-point number?
Answer: (b) float()
4. Which of the following is a relational operator?
Answer: (c) Both (a) and (b)

B. Fill in the blanks.


1. Each component in a Python program is called a Token.
2. A prompt is used to display a message in the input () function.
3. Python uses ASCII character set.
4. Boolean literals have two values, true and false.

C. Write 'T' for true and 'F' for false for the following statements.
1. Tokens are also called variables. → False
2. You can use keywords to name a variable. → False
3. Relational operators are used to compare values. → True
4. You cannot perform arithmetic operations on strings. → False

D. Define the following


1. Token
A token is the smallest individual unit of a Python program. Python breaks a program into
tokens during execution. Examples of tokens are keywords, identifiers, operators, literals, and
separators.

2. Literals
Literals are fixed values that are directly written in a program and do not change. Examples of
Literals are numbers, strings, and Boolean values.
Example:
x = 10 # 10 is a numeric literal
name = "Ram" # "Ram" is a string literal

3. input()
The input() function is used to take input from the user at runtime. The value entered by the
user is always treated as a string.
Example:
name = input("Enter your name: ")

4. float()
The float() function is used to convert a number or string into a floating-point (decimal) number.
Example:
x = float(5)
Here, x becomes 5.0.
E. Short answer questions
1. What is the use of variables?
Answer: Variables in Python are primarily used as containers to store and manage data in
memory. They provide a way to label data with a descriptive name, making the code more
readable, maintainable, and flexible.

2. What is a keyword? Name any two keywords.


Answer: A keyword is a word that is reserved by the Python programming language because it
has a special meaning or function. These words cannot be used as names for variables,
functions, or any other identifiers.
Examples: if, else, while, for etc.

3. What is the use of relational operators?


Answer: Relational operators in Python are used to compare two operands and evaluate their
relationship and returning a boolean value - True or False. They are essential for decision-
making, enabling conditional statements and loop control. Examples: >, <, ==,!= etc.

4. Write the names of logical operators.


Answer: The logical operators in Python are the keywords and, or, and not. They are used to
combine conditional statements and return a Boolean result - True or False.

F. Long answer questions

1. Explain data types using examples.


Data types in Python are a way to classify data items. They represent the kind of value, which
determines what operations can be performed on that data. The following are standard or built-
in data types in Python:
• Numeric: int, float, complex
• Sequence Type: string, list, tuple
• Mapping Type: dict
• Boolean: bool

2. Explain various arithmetic operators in Python using an example.


Python provides several arithmetic operators to perform common mathematical operations.
These operators work with various numeric types, including integers and floats. Here are the
primary arithmetic operators in Python, with examples using variables a = 10 and b = 3:

Example
Operator Name Description Result
(Python)

+ Addition Adds the two operands. a+b 13

- Subtraction Subtracts the right operand from the left. a-b 7

* Multiplication Multiplies the two operands. a*b 30

Divides the left operand by the right, resulting in


/ Division a/b 3.333...
a float.
Divides and returns the integer part of the quotient,
// Floor Division a // b 3
rounding down to the nearest whole number.

% Modulus Returns the remainder of the division. a%b 1

Raises the left operand to the power of the right


** Exponentiation a ** b 1000
operand.

3. What is the purpose of int() function? Explain with an example.

The purpose of the int() function in Python is to convert a specified value into an integer number.
It allows us to change the data type of a variable or a value, which is crucial for mathematical
operations or comparisons that require integer inputs.
Example:
x = int("20")
y = int(5.7)
Here, x becomes 20 and y becomes 5.

4. What is the significance of comments in Python programs?

Comments in Python programs serve as essential tools for enhancing code readability,
maintainability, and collaboration. They are lines of text that are ignored by the interpreter
during execution. Key significance of Comments are-
➢ Improved Readability
➢ Enhanced Maintainability
➢ Code Understanding for Future Self

Types of Comments in Python:


➢ Single-Line Comments:
o Initiated with the # symbol, they comment out a single line of code.
➢ Multi-Line Comments:
o Enclosed within triple quotes (''' or '''), they can span multiple lines.

You might also like