The document contains a series of Python programming assignments that require writing code to perform various tasks, such as checking if a number is positive, even or odd, determining if a number is three digits, checking voting eligibility based on age, finding the largest of two numbers, and calculating the absolute value of a number. Each task includes a brief description and corresponding code snippets. The assignments aim to enhance programming skills in Python.
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 ratings0% found this document useful (0 votes)
14 views
Python Assignment -4
The document contains a series of Python programming assignments that require writing code to perform various tasks, such as checking if a number is positive, even or odd, determining if a number is three digits, checking voting eligibility based on age, finding the largest of two numbers, and calculating the absolute value of a number. Each task includes a brief description and corresponding code snippets. The assignments aim to enhance programming skills in Python.
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/ 6
Python Assignment -4
1. Write a program to accept a number and display a
message whether entered number is positive or not. Code: A=int(input("Enter a Number=")) if A<0: print("your number is negative") else: print("your number is positive") 2. Write a program to accept a number and display a message whether entered number is even or odd. Code: A=int(input("Enter a Number=")) A=A%2 if A==0: print("your number is an even number") else: print("your number is an odd number") print("Thank You") 3. Write a program to accept a number and check whether it is in three digit or not. Code: A=int(input("Enter a Number=")) if 99<A<1000: print("your number is a three digit number") else: print("your number is not three digit numberr") print("Thank You") 4. Write a program to accept age of a person and display a message indicating a person is eligible for voting or not. Code: A=int(input("Enter a Number=")) if A>17: print("your given age is elegible") else: print("your given age is illegebale") print("Thank You") 5. Write a program to accept two numbers and display largest of two entered numbers. Code: A=int(input("Enter the First Number=")) B=int(input("Enter the Second Number")) if A>B: print(A,"is greater than ",B) else: print(B,"is greater than ",A) 6. Write a program to accept a number and display it’s absolute value, that means if entered number if -ve then convert it to positive otherwise display same number. Code: A=int(input("Enter a Number=")) if A<0: B=A*-1 print(A,"is negative and the positive value is ",B) else: print(A," is positive")