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

Simple Python Exercises

The document contains a series of simple Python exercises designed to practice basic programming concepts. Exercises include checking if a number is positive, negative, or zero; determining if a number is even or odd; creating a simple calculator; grading based on marks; and more. Each exercise provides expected input/output guidelines for user interaction.

Uploaded by

br24102000
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

Simple Python Exercises

The document contains a series of simple Python exercises designed to practice basic programming concepts. Exercises include checking if a number is positive, negative, or zero; determining if a number is even or odd; creating a simple calculator; grading based on marks; and more. Each exercise provides expected input/output guidelines for user interaction.

Uploaded by

br24102000
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

Simple Python Exercises

Exercise 1: Positive, Negative, or Zero

Write a program that asks the user for a number and checks:

• If it’s positive

• If it’s negative

• Or if it’s zero

Expected Input/Output:

Exercise 2: Even or Odd

Write a program to check whether a given number is even or odd using the modulus (%)
operator.

Expected Input/Output:

Exercise 3: Simple Calculator

Write a program that takes two numbers from the user and prints:

• Their sum

• Their difference

• Their product

• Their quotient

Expected Input/Output:
Exercise 4: Grade Checker

Write a program that asks the user for their marks (0–100).

• If marks ≥ 90 → Print “Grade A”

• If marks ≥ 75 → Print “Grade B”

• If marks ≥ 50 → Print “Grade C”

• Else → Print “Fail”

Expected Input/Output:

Exercise 5: Largest of Three Numbers

Write a program that asks the user to enter three numbers and prints the largest number
using if–else.

Expected Input/Output:
Python Practice Exercises (Set 2)

Exercise 1: Temperature Check

Ask the user to enter the current temperature.

• If temp ≥ 30 → print "It's Hot"

• If temp between 15 and 29 → print "It's Warm"

• Else → print "It's Cold"

Exercise 2: Number Divisible Check

Take a number as input and check:

• If divisible by 5 → print "Divisible by 5"

• Else → print "Not divisible by 5"

Exercise 3: Simple Discount Calculator

Ask the user for the bill amount.

• If bill ≥ 1000 → give 10% discount

• Else → no discount

• Print the final amount.

Exercise 4: Leap Year Checker

Take a year as input.

• If divisible by 400 → Leap year

• Else if divisible by 4 but not 100 → Leap year

• Else → Not a leap year

Exercise 5: Login System

Ask the user to enter a username and password.

• If username = "admin" and password = "1234" → print "Login Successful"

• Else → print "Login Failed"


Exercise 6: Rectangle or Square

Take input for length and width.

• If length == width → print "It's a Square"

• Else → print "It's a Rectangle"

You might also like