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

50_Simple_Python_Programs

The document contains 50 simple Python programs with answers that cover basic programming concepts. Examples include checking if a number is positive or negative, determining if a year is a leap year, and implementing a simple grading system. Each program is presented with code snippets and corresponding outputs.

Uploaded by

seenusathish2003
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)
6 views2 pages

50_Simple_Python_Programs

The document contains 50 simple Python programs with answers that cover basic programming concepts. Examples include checking if a number is positive or negative, determining if a year is a leap year, and implementing a simple grading system. Each program is presented with code snippets and corresponding outputs.

Uploaded by

seenusathish2003
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/ 2

50 Simple Easy Python Programs with Answers

1. Check if number is positive, negative or zero

num = 3

if num > 0:

print("Positive")

elif num < 0:

print("Negative")

else:

print("Zero")

2. Check if number is even or odd

num = 4

print("Even" if num % 2 == 0 else "Odd")

3. Check if a year is a leap year

year = 2024

print("Leap year" if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) else "Not a leap year")

4. Find greatest of 3 numbers

a, b, c = 10, 20, 5

print(max(a, b, c))

5. Check if character is vowel or consonant

char = 'e'

print("Vowel" if char.lower() in 'aeiou' else "Consonant")

6. Check if a person is eligible to vote

age = 18

print("Eligible" if age >= 18 else "Not eligible")


7. Check if number is divisible by 5 and 11

num = 55

print("Divisible" if num % 5 == 0 and num % 11 == 0 else "Not divisible")

8. Check if character is uppercase or lowercase

ch = 'A'

print("Uppercase" if ch.isupper() else "Lowercase")

9. Simple grading system

marks = 85

if marks >= 90:

grade = 'A'

elif marks >= 75:

grade = 'B'

elif marks >= 60:

grade = 'C'

else:

grade = 'D'

print(grade)

10. Check if a number is in a range

n = 10

print("In range" if 1 <= n <= 100 else "Out of range")

You might also like