Professional Documents
Culture Documents
Shared Textoj
Shared Textoj
Code:
python
Copy code
number = int(input("Enter a number: "))
if number > 0:
print("The number is positive.")
elif number < 0:
print("The number is negative.")
else:
print("The number is zero.")
Question 2
Problem: Determine the largest of three numbers.
Code:
python
Copy code
a = int(input("Enter the first number: "))
b = int(input("Enter the second number: "))
c = int(input("Enter the third number: "))
Code:
python
Copy code
year = int(input("Enter a year: "))
Code:
python
Copy code
score = float(input("Enter the score: "))
Code:
python
Copy code
char = input("Enter a character: ").lower()
if char in 'aeiou':
print(char, "is a vowel.")
else:
print(char, "is a consonant.")
Question 6
Problem: Determine if a number is even or odd.
Code:
python
Copy code
number = int(input("Enter a number: "))
if number % 2 == 0:
print(number, "is even.")
else:
print(number, "is odd.")
Question 7
Problem: Determine if a person is a child, teenager, adult, or senior based on age.
Code:
python
Copy code
age = int(input("Enter age: "))
Code:
python
Copy code
distance = float(input("Enter distance traveled (in km): "))
if distance <= 5:
fare = 5
elif distance <= 15:
fare = 10
else:
fare = 20
Code:
python
Copy code
age = int(input("Enter age: "))
citizenship = input("Are you a citizen (yes/no)? ").lower()
Code:
python
Copy code
number = int(input("Enter a number: "))
Question 22
Problem: Determine if a number is a perfect square.
Code:
python
Copy code
import math
if math.isqrt(number) ** 2 == number:
print(number, "is a perfect square.")
else:
print(number, "is not a perfect square.")
Question 23
Problem: Determine if a person is eligible for a senior citizen discount.
Code:
python
Copy code
age = int(input("Enter age: "))
Code:
python
Copy code
number = int(input("Enter a number: "))
low = int(input("Enter the lower bound: "))
high = int(input("Enter the upper bound: "))
Code:
python
Copy code
score = float(input("Enter the percentage score: "))