0% found this document useful (0 votes)
9 views

Worksheet 2 Answers

The document contains four separate code snippets that prompt the user for input and provide output based on conditions. The first snippet compares two numbers to determine the larger one, the second checks if a number is even or odd, the third assesses voting eligibility based on age, and the fourth identifies whether a number is negative, zero, or positive. Each snippet uses simple conditional statements to deliver the results.

Uploaded by

????
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Worksheet 2 Answers

The document contains four separate code snippets that prompt the user for input and provide output based on conditions. The first snippet compares two numbers to determine the larger one, the second checks if a number is even or odd, the third assesses voting eligibility based on age, and the fourth identifies whether a number is negative, zero, or positive. Each snippet uses simple conditional statements to deliver the results.

Uploaded by

????
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

A1) A=int(input("Enter the first number"))

B=int(input("Enter the second number"))

if A>B:

print("The bigger number, out of these two numbers, is",A)

if B>A:

print("The bigger number, out of these two numbers, is",B)

A2) A=int(input("Enter a number"))

if A%2==0:

print("It's an even number!")

else:

print("It's an odd number!")


A3) A=input("Enter your name")

B=int(input("Enter your age"))

if B<18:

print(A, "You are not eligible to vote yet!")

if B==18:

print(A, "You are eligible to vote!")

if B>18:

print(A, "You are eligible to vote!")

A4) B=int(input("Enter a random number"))


if B<0:

print("It's a negative number!")

if B==0:

print("It's zero!")

if B>0:

print("It's a positive number!")

You might also like