0% found this document useful (0 votes)
203 views2 pages

Python Quiz for Class 7 Students

The document contains a Python question set for Class 7, including fill-in-the-blanks, multiple choice, true or false, short answer, and programming questions with answers. It covers basic concepts such as Python's history, file extensions, functions, variables, and programming examples. The content is designed to test students' understanding of Python programming fundamentals.

Uploaded by

arindampradhan58
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)
203 views2 pages

Python Quiz for Class 7 Students

The document contains a Python question set for Class 7, including fill-in-the-blanks, multiple choice, true or false, short answer, and programming questions with answers. It covers basic concepts such as Python's history, file extensions, functions, variables, and programming examples. The content is designed to test students' understanding of Python programming fundamentals.

Uploaded by

arindampradhan58
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

Python Question Set with Answers – Class 7

A. Fill in the blanks (with answers):


1. Python was developed by Guido van Rossum in the year 1991.
2. The extension of a Python file is .py.
3. The print() function is used to display output.
4. The input() function takes input from the user.
5. Variables are used to store data in a program.

B. Multiple Choice Questions (with answers):


1. (c) # comment
2. (b) name_1
3. (b) 11
4. (c) type()
5. (b) **

C. True or False (with answers):


1. False
2. True
3. True
4. True
5. False

D. Short Answer Questions (with answers):


1. Python is used for web development, data analysis, AI, and automation.
2. A variable is a name that stores data. Example: x = 10
3. Keywords are reserved words in Python, like if, while, for.
4. = is used for assignment, while == is used for comparison.
5. Indentation defines blocks of code in Python and maintains readability.

E. Programming Questions (with answers):


1. Add two numbers:
x = int(input("Enter first number: "))
y = int(input("Enter second number: "))
print("Sum:", x + y)

2. Area of rectangle:
l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
print("Area =", l * b)

3. Display personal info:


print("Name: Arjun")
print("Age: 12")
print("School: ABC School")

4. Swap two numbers:


a=5
b = 10
a, b = b, a
print(a, b)

5. Square and cube:


n = int(input("Enter a number: "))
print("Square =", n**2)
print("Cube =", n**3)

Common questions

Powered by AI

Comments, initiated by the '#' symbol in Python, increase code maintainability by providing explanations and context for specific code segments, which is helpful for both the original author and other developers who may work on the code in the future. This practice reduces misunderstandings and facilitates easier code updates and debugging .

Variables in Python act as storage containers for data, allowing programmers to store, retrieve, and manipulate this data throughout the program. For example, in the statement x = 10, the variable 'x' stores the integer 10, enabling various mathematical operations and logical evaluations using 'x' throughout the code .

The assignment operator '=' is used to assign a value to a variable, such as x = 5. In contrast, the comparison operator '==' checks if two values are equal, for example, if (x == 5): checks if x holds the value 5. These operators serve different purposes in controlling data flow and logic within a program .

Indentation in Python is crucial as it defines the blocks of code and influences the program's execution flow. Unlike many other languages that use braces or other syntax to delimit blocks, Python relies on indentation, which enforces consistent formatting and readability, helping to prevent errors and maintain clean code .

Python's versatility, facilitated by its straightforward syntax and rich libraries, allows it to be easily applied in various domains like AI, which benefits from libraries like TensorFlow, and web development, which leverages frameworks such as Django. Additionally, a strong community support network provides continual resources, documentation, and development tools necessary for effective problem-solving and innovation .

Python is widely used for web development, data analysis, artificial intelligence, and automation due to its simplicity and readability. Its extensive standard libraries, support for multiple programming paradigms, and strong community support make it particularly suitable for these applications .

Keywords are reserved words that have predefined meanings and functionalities within Python, such as 'if', 'else', 'for', and 'while'. They control the structure and flow of a program, and misusing them can lead to syntax errors or unintended behavior. Therefore, developers must use them correctly and avoid using these words as variable names .

Arithmetic operators in Python, such as +, -, *, and **, are used to perform basic calculations. A program to calculate the square and cube of a number can be written as: n = int(input("Enter a number: ")) print("Square =", n**2) print("Cube =", n**3), where ** denotes exponentiation, allowing calculation of powers .

User input in Python can be managed using the input() function, which captures input as a string. This input can be converted to required data types for processing. For example, capturing two integers and printing their sum is managed with the program: x = int(input("Enter first number: ")) y = int(input("Enter second number: ")) print("Sum:", x + y).

Swapping two variables in Python can be efficiently done using multiple assignment. For example, to swap variables a and b, the code a, b = b, a swaps their values without the need for a temporary variable. This approach leverages Python's tuple unpacking capability .

You might also like