diff --git a/basic programming/2nd task/1.py b/basic programming/2nd task/1.py new file mode 100644 index 0000000..6b0c319 --- /dev/null +++ b/basic programming/2nd task/1.py @@ -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.") \ No newline at end of file diff --git a/basic programming/2nd task/2.py b/basic programming/2nd task/2.py new file mode 100644 index 0000000..78ebefd --- /dev/null +++ b/basic programming/2nd task/2.py @@ -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}") \ No newline at end of file diff --git a/basic programming/2nd task/3.py b/basic programming/2nd task/3.py new file mode 100644 index 0000000..9055239 --- /dev/null +++ b/basic programming/2nd task/3.py @@ -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") diff --git a/basic programming/2nd task/4.py b/basic programming/2nd task/4.py new file mode 100644 index 0000000..7403f68 --- /dev/null +++ b/basic programming/2nd task/4.py @@ -0,0 +1,4 @@ +# Q4 + +for number in range(2, 101, 2): + print(number) \ No newline at end of file diff --git a/basic programming/2nd task/5.py b/basic programming/2nd task/5.py new file mode 100644 index 0000000..4ea1b16 --- /dev/null +++ b/basic programming/2nd task/5.py @@ -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)) \ No newline at end of file diff --git a/basic programming/2nd task/6.py b/basic programming/2nd task/6.py new file mode 100644 index 0000000..907ea7f --- /dev/null +++ b/basic programming/2nd task/6.py @@ -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.") \ No newline at end of file