0% found this document useful (0 votes)
2 views1 page

Python Assignment 3

The document outlines a homework assignment focused on Python operators, including arithmetic, relational, and logical operators. It includes tasks such as writing programs to perform calculations, check voting eligibility, and demonstrate type casting. Additionally, it requires the creation of an advanced calculator program with various functionalities and error handling.

Uploaded by

harshsingh26603
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)
2 views1 page

Python Assignment 3

The document outlines a homework assignment focused on Python operators, including arithmetic, relational, and logical operators. It includes tasks such as writing programs to perform calculations, check voting eligibility, and demonstrate type casting. Additionally, it requires the creation of an advanced calculator program with various functionalities and error handling.

Uploaded by

harshsingh26603
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
You are on page 1/ 1

Homework Assignment

Session 03 - Operators

Questions:

Questions:

1. Understanding Operators:
a. What are operators in Python, and why are they important?
b. List and describe three types of operators with examples.
c. Explain the difference between arithmetic, relational, and logical operators.
2. Arithmetic Operators:
a. Write a Python program that takes two numbers as input and calculates:
i. Their sum (+)
ii. Their difference (-)
iii. Their product (*)
iv. Their quotient (/)
v. Their remainder (%)
b. Add comments explaining each operation.
3. Relational and Logical Operators:
a. What are relational operators? Provide three examples of their usage.
b. What are logical operators? Explain how and, or, and not work with
examples.
c. Write a Python program that asks the user to enter their age and checks if
they are eligible to vote (age >= 18). Use both relational and logical operators.
4. Type Casting in Python:
a. What is type casting, and why is it necessary?
b. Convert the following values into different data types and print the results:
i. Integer to float
ii. Float to integer
iii. String containing a number to an integer
c. Write a program that asks the user for their birth year, converts it into an
integer, and calculates their current age.
5. Advanced Calculator Project:
a. Create a Python program that functions as a calculator with the following
features:
i. Takes two numbers as input from the user.
ii. Provides a menu for the user to choose an operation: addition,
subtraction, multiplication, division, modulus, exponentiation (**), and
floor division (//).
iii. Uses conditional statements to perform the chosen operation.
iv. Ensures the program handles division by zero with an appropriate
error message.
v. Implements a loop to allow multiple calculations until the user chooses
to exit.

RANCHOVATION LABS PRIVATE LIMITED


www.rancholabs.com

You might also like