0% found this document useful (0 votes)
3 views4 pages

? Python Assignment - 01

This Python assignment focuses on practicing variables, data types, and operators. It includes tasks related to creating variables, performing arithmetic operations, using assignment and comparison operators, and applying logical operators. Additionally, there is a real-life example involving calculations and a bonus task for user input, with instructions to comment and maintain code readability.

Uploaded by

sufyantech6
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)
3 views4 pages

? Python Assignment - 01

This Python assignment focuses on practicing variables, data types, and operators. It includes tasks related to creating variables, performing arithmetic operations, using assignment and comparison operators, and applying logical operators. Additionally, there is a real-life example involving calculations and a bonus task for user input, with instructions to comment and maintain code readability.

Uploaded by

sufyantech6
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 Assignment – 01

Topics: Variables, Data Types & Operators

Dear Students,​
This assignment will help you practice the basics of Python. Please attempt all questions.

Q1: Variables & Data Types


1.​ Create the following variables:​

○​ name → your full name​

○​ age → your age​

○​ is_student → a boolean value (True/False)​

2.​ Print all variables in one line.​

3.​ Print the data type of each variable using type().​

Q2: Arithmetic Operators


Let x = 20 and y = 6.​
Perform and print the results of:

●​ Addition​

●​ Subtraction​

●​ Multiplication​

●​ Division​
●​ Floor Division​

●​ Modulus​

●​ Exponent​

Q3: Assignment Operators


Let num = 10.

1.​ Add 5 to num using the += operator.​

2.​ Multiply num by 2 using the *= operator.​

3.​ Subtract 4 from num using the -= operator.​

4.​ Print the final value of num.​

Q4: Comparison Operators


Take a = 15 and b = 12.​
Check and print the results of the following comparisons:

●​ a > b​

●​ a < b​

●​ a == b​

●​ a != b​

●​ a >= b​

●​ a <= b​
Q5: Logical Operators
Let p = True and q = False.​
Check and print the result of:

●​ p and q​

●​ p or q​

●​ not p​

●​ not q​

Q6: Real-Life Example


The price of one notebook is 80 rupees.

●​ If you buy 7 notebooks, calculate the total price.​

●​ If you have 600 rupees, check (using comparison operator) whether your money is
enough to buy them or not.​

●​ Print the result in a clear message.​

Q7: Bonus (Optional)


Take two numbers as input from the user.

●​ Print their sum.​

●​ Print whether the first number is greater than the second number or not.​
📌 Instructions
●​ Use comments (#) to explain each step.​

●​ Keep your code neat and readable.​

●​ Submit the vscode .py or google colab file before the deadline.​

You might also like