uploaded 1-6

This commit is contained in:
2024-12-07 22:06:50 +02:00
parent c231dce57f
commit 017145b529
6 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# Q1
user_input = int(input("Enter a number: "))
if user_input % 2 == 0: print("Number is even.")
else: print("Number is odd.")
if user_input > 0: print("Number is positive.")
elif user_input < 0: print("Number is negative.")
else: print("Number is 0.")

View File

@@ -0,0 +1,14 @@
# Q2
num1 = float(input("Enter 1st number: "))
num2 = float(input("Enter 2nd number: "))
num3 = float(input("Enter 3rd number: "))
if num1 > num2:
num1, num2 = num2, num1
if num1 > num3:
num1, num3 = num3, num1
if num2 > num3:
num2, num3 = num3, num2
print(f"Sorted numbers: {num1}, {num2}, {num3}")

View File

@@ -0,0 +1,19 @@
# Q3
# Get salary
salary = float(input("Input salary: "))
# Calcuation of tax
tax = 0
if salary > 7000:
# If above 7000NIS, deduct 30% from the sum above 7000NIS
tax += (salary - 7000) * 0.30
salary = 7000 # Set salary after deducting taxed sum
if salary > 5000:
# If above 5000NIS, deduct 20% from the sum above 5000NIS
tax += (salary - 5000) * 0.20
# Print taxes
print(f"Sum of taxes: {tax:.2f}NIS")

View File

@@ -0,0 +1,4 @@
# Q4
for number in range(2, 101, 2):
print(number)

View File

@@ -0,0 +1,11 @@
# Q5
num1, num2, num3, num4, num5, num6, num7, num8, num9, num10 =\
int(input("Enter number:")), int(input("Enter number:")),\
int(input("Enter number:")), int(input("Enter number:")),\
int(input("Enter number:")), int(input("Enter number:")),\
int(input("Enter number:")), int(input("Enter number:")),\
int(input("Enter number:")), int(input("Enter number:"))
print(max(num1, num2, num3, num4, num5, num6, num7, num8, num9, num10))
print(min(num1, num2, num3, num4, num5, num6, num7, num8, num9, num10))

View File

@@ -0,0 +1,16 @@
# Q6
scale = input("Enter 'F' for Fahrenheit, 'C' for celsius: ")
if (scale.lower() != 'f' and scale.lower() != 'c'):
print("Improper scale.")
print("Quitting...")
exit()
degrees = int(input("Enter temperature: "))
if scale.lower() == 'f':
converted_value = round(((degrees-32)*5/9))
print(f"{degrees} degrees Fahrenheit are {converted_value} degrees Celsius.")
else:
converted_value = round((9*degrees/5)+32)
print(f"{degrees} degrees Celsius are {converted_value} degrees Fahrenheit.")