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

Class6 Python Operators Worksheet

This document is a Class 6 worksheet focused on introducing Python and its operators. It includes fill-in-the-blank questions, true or false statements, short answer questions, and practical programming tasks. The worksheet covers basic concepts of Python programming, operator types, and application-based problems to reinforce learning.

Uploaded by

Vishal Pandey
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)
50 views3 pages

Class6 Python Operators Worksheet

This document is a Class 6 worksheet focused on introducing Python and its operators. It includes fill-in-the-blank questions, true or false statements, short answer questions, and practical programming tasks. The worksheet covers basic concepts of Python programming, operator types, and application-based problems to reinforce learning.

Uploaded by

Vishal Pandey
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

Class 6 Worksheet: Introduction to Python &

Operators in Python
Part A – Introduction to Python

1. Fill in the blanks:


a) Python is a ___________ level programming language.
b) The creator of Python is ___________.
c) Python files are saved with the extension ___________.
d) Python was first released in the year ___________.
e) In Python, instructions written by the user are called ___________.

2. State True or False:


a) Python is case-sensitive. (____)
b) Python programs can only run on Windows. (____)
c) Python can be used for making games and websites. (____)
d) In Python, we must declare the data type of a variable before using it. (____)

3. Short answer questions:


a) What is Python?
b) Name any three areas where Python is used.
c) Write the command to print “Hello World” on the screen in Python.

Part B – Operators in Python

4. Match the following operators with their names:


+ ( ) a) Comparison Operator
== ( ) b) Assignment Operator
* ( ) c) Arithmetic Operator
= ( ) d) Logical Operator
and ( ) e) Used to compare two values

5. Fill in the blanks:


a) In Python, the operator used for division is ___________.
b) The operator used for exponent (power) is ___________.
c) The operator used to check if two values are equal is ___________.
d) The operator used to combine conditions is ___________.

6. State the type of each operator:


a) x + y → ___________
b) x == y → ___________
c) x and y → ___________
d) x = y → ___________

7. Write the output of the following in Python:


a) print(5 + 3 * 2) = ______
b) print(10 // 3) = ______
c) print(2 ** 3) = ______
d) print(7 % 3) = ______

8. Write a Python program to:


a) Add two numbers entered by the user.
b) Check whether a number entered by the user is greater than 10.
Part C – Application-Based Problems

1. Predict the output:


a = 10
b=3
print(a % b)
print(a // b)
print(a ** b)

2. Variable and Operator Application:


x=5
y=x+2
x=x*y
print(x)

3. Write a Python program to:


- Ask the user to input two numbers
- Add them
- Multiply the sum by 10
- Display the result

4. Guess the error:


x=4
y=2
print(x + y

5. Logical Operator Application:


x=7
y=5
print(x > 5 and y < 3)
print(x != y or y == 5)

6. Program Writing:
Write a Python program to take three numbers from the user and print:
- Their sum
- Their average

7. Real-life scenario:
You went to a shop. The cost of 1 pencil is ■5. You buy 8 pencils. Write a Python program to
calculate and print the total cost.

8. Mixed Operators:
a=2
b=3
c=4
print(a + b * c)
print((a + b) * c)

9. Discount Problem:
A shirt costs ■500. The shopkeeper gives a discount of 20%. Write a Python program to calculate
the price after discount.

10. Temperature Conversion:


Write a Python program to input temperature in Celsius and convert it to Fahrenheit using the
formula:
F = (9/5) * C + 32

Common questions

Powered by AI

Python's dynamic typing simplifies variable operations, as it doesn't require type declarations, but it can lead to run-time type errors if variables are unexpectedly reassigned incompatible types. This flexibility requires robust error handling and debugging strategies, such as using try-except blocks for error capture, writing unit tests to validate different execution paths, and employing logging to trace and diagnose behavior during variable operations .

Python is commonly used in web development, data analysis, and artificial intelligence. In web development, frameworks like Django and Flask simplify the creation of complex server-side code. Python's extensive libraries, such as Pandas and NumPy, enhance data analysis through efficient data manipulation and computation. For AI, libraries like TensorFlow and PyTorch provide the necessary tools for building machine learning models, leveraging Python's simple syntax and integration capabilities .

The modulus operator '%' in Python returns the remainder of a division operation, which can be strategically used in currency problems to calculate leftover change. For example, determining the remaining cents when dividing an amount by the monetary unit like dollars. Similarly, it aids in time calculations by converting total minutes to hours and minutes, where the remainder represents the extra minutes past an hour marker .

Python is a dynamically typed language, meaning variables do not require explicit type declarations. This feature enhances program flexibility by allowing variables to be reassigned to different data types without modifying variable declarations, fostering development speed and reducing code verbosity. This dynamic typing supports flexible coding styles and rapid prototyping, which is advantageous in data analysis and iterative development environments .

Executing these operations results in: 'a % b' yields 1, as it computes the remainder of 10 divided by 3. 'a // b' results in 3, as it performs integer division that discards any fractional part. 'a ** b' gives 1000, because it calculates 10 raised to the power of 3. Each operation showcases Python's arithmetic capabilities: modulus for remainders, floor division for integer division, and exponentiation for powers .

In Python, the addition operation '+' is an arithmetic operator used for summing numbers. The equality check '==' is a comparison operator that determines if two values are equal. The 'and' operation is a logical operator used to combine two Boolean expressions, returning True if both are True. The assignment operator '=' assigns the right-hand value to the left-hand variable. Each category caters to different types of operations needed in programming: arithmetic for calculations, comparison for decision-making, logical for evaluating conditions, and assignment for data storage and initializations .

To calculate the discounted price, use the formula `discounted_price = original_price * (1 - discount)`. In Python: `original_price = 500; discount = 0.20; discounted_price = original_price * (1 - discount); print(discounted_price)`. This calculation multiplies the original price by 80% (1 - 0.20), reflecting a 20% reduction from the base price .

Logical operators in Python, like 'and', 'or', and 'not', enable complex decision-making by evaluating multiple conditions simultaneously. For instance, in a conditional statement `if x > 5 and y < 10:`, both conditions must be true for the block to execute, effectively filtering scenarios that meet specific criteria. These operators broaden the scope of condition handling, allowing for the creation of more intricate and tailored decision pathways in programs .

The expression 'print(x + y 5)' results in a syntax error as it improperly concatenates a constant value without an operator. To mitigate such errors during development, developers should ensure operators are correctly placed between operands, utilize integrated development environments (IDEs) that provide syntax highlighting and error checking, and apply thorough code review and testing practices .

In Python, operators can create solutions for practical tasks, like averaging numbers. A program could prompt user input for three numbers, sum them using the '+' operator, and divide by three using the '/' operator to find the average. For example: `a, b, c = map(float, input("Enter three numbers: ").split()); average = (a + b + c) / 3; print("Average:", average)`. This logically combines arithmetic operators to deliver user-driven calculations .

You might also like