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

Number and Year Validation Scripts

The document contains a series of Python code snippets that perform basic tasks such as checking if a number is positive, negative, or zero, finding the largest of three numbers, determining if a year is a leap year, checking voting eligibility based on age, and evaluating pass or fail based on marks. Each section includes user input prompts and conditional statements to execute the respective logic. The code is structured in a straightforward manner for easy understanding and implementation.

Uploaded by

mihirraj0987
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)
8 views1 page

Number and Year Validation Scripts

The document contains a series of Python code snippets that perform basic tasks such as checking if a number is positive, negative, or zero, finding the largest of three numbers, determining if a year is a leap year, checking voting eligibility based on age, and evaluating pass or fail based on marks. Each section includes user input prompts and conditional statements to execute the respective logic. The code is structured in a straightforward manner for easy understanding and implementation.

Uploaded by

mihirraj0987
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

# ----------------------------------------

# 1. Check whether a number is positive, negative, or zero


# ----------------------------------------
num = int(input("Enter a number: "))
if num > 0:
print("The number is positive.")
elif num < 0:
print("The number is negative.")
else:
print("The number is zero.")

# ----------------------------------------
# 2. Find the largest of three numbers
# ----------------------------------------
a = int(input("\nEnter first number: "))
b = int(input("Enter second number: "))
c = int(input("Enter third number: "))
if a >= b and a >= c:
print("The largest number is", a)
elif b >= a and b >= c:
print("The largest number is", b)
else:
print("The largest number is", c)

# ----------------------------------------
# 3. Check if a year is a leap year
# ----------------------------------------
year = int(input("\nEnter a year: "))
if (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0):
print("It is a leap year.")
else:
print("It is not a leap year.")

# ----------------------------------------
# 4. Check if a person is eligible to vote
# ----------------------------------------
age = int(input("\nEnter your age: "))
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")

# ----------------------------------------
# 5. Print 'Pass' if marks >= 40 else 'Fail'
# ----------------------------------------
marks = int(input("\nEnter your marks: "))
if marks >= 40:
print("Pass")
else:
print("Fail")

You might also like