commit 288c7e127a7eb3eb249aa17ca8512436029ac284 Author: Eduard Prigoana Date: Sat Mar 15 11:11:42 2025 +0200 first hw batch 15.3.25 at 11:09 diff --git a/py/BasicIfStatements/BasicIfStatements.pdf b/py/BasicIfStatements/BasicIfStatements.pdf new file mode 100644 index 0000000..a9906bf Binary files /dev/null and b/py/BasicIfStatements/BasicIfStatements.pdf differ diff --git a/py/BasicIfStatements/challenge1.py b/py/BasicIfStatements/challenge1.py new file mode 100644 index 0000000..bb45f10 --- /dev/null +++ b/py/BasicIfStatements/challenge1.py @@ -0,0 +1,8 @@ +# Ask the user for their age +age = int(input("Enter your age: ")) + +# Check if the user is 18 or older +if age >= 18: + print("You can vote") +else: + print("You cannot vote yet") \ No newline at end of file diff --git a/py/BasicIfStatements/challenge2.py b/py/BasicIfStatements/challenge2.py new file mode 100644 index 0000000..6dff53f --- /dev/null +++ b/py/BasicIfStatements/challenge2.py @@ -0,0 +1,10 @@ +# Question: Ask the user to enter a password. If they enter “letmein”, display the message “access granted”. + +# Ask the user to enter the password +password = input("Enter your password: ").strip() + +# Check if the password is "letmein" +if password == "letmein": + print("Access granted") +else: + print("Access denied") \ No newline at end of file diff --git a/py/BasicIfStatements/challenge3.py b/py/BasicIfStatements/challenge3.py new file mode 100644 index 0000000..ae4da0b --- /dev/null +++ b/py/BasicIfStatements/challenge3.py @@ -0,0 +1,12 @@ +# Start of the program +num = int(input("Enter a number: ")) + +# Check if the number is greater than 100 +if num > 100: + print("Thank you") +else: + num += 100 + print("I have changed your number as it was too low") + +# Output the final number +print("Your number is", num) \ No newline at end of file diff --git a/py/IfElseStatements/IfElseStatements.pdf b/py/IfElseStatements/IfElseStatements.pdf new file mode 100644 index 0000000..e2efa97 Binary files /dev/null and b/py/IfElseStatements/IfElseStatements.pdf differ diff --git a/py/IfElseStatements/challenge1.py b/py/IfElseStatements/challenge1.py new file mode 100644 index 0000000..01fee87 --- /dev/null +++ b/py/IfElseStatements/challenge1.py @@ -0,0 +1,10 @@ +# Question: Ask if the user likes pizza. If they answer “yes” display “I like pizza too”, otherwise display “My favourite food is pizza.” + +# Ask the user if they like pizza +response = input("Do you like pizza? (yes/no): ").strip().lower() + +# Check the response and display appropriate message +if response == "yes": + print("I like pizza too!") +else: + print("My favourite food is pizza.") \ No newline at end of file diff --git a/py/IfElseStatements/challenge2.py b/py/IfElseStatements/challenge2.py new file mode 100644 index 0000000..45aef47 --- /dev/null +++ b/py/IfElseStatements/challenge2.py @@ -0,0 +1,10 @@ +# Question: Change your password program you created earlier. If they enter “letmein”, display the message “access granted” otherwise display “access denied”. + +# Ask the user to enter the password +password = input("Enter your password: ").strip() + +# Check if the password is "letmein" +if password == "letmein": + print("Access granted") +else: + print("Access denied") \ No newline at end of file diff --git a/py/IfElseStatements/challenge3.py b/py/IfElseStatements/challenge3.py new file mode 100644 index 0000000..e69de29 diff --git a/py/basicifstatements/challenge1.py b/py/basicifstatements/challenge1.py new file mode 100644 index 0000000..3b8cc42 --- /dev/null +++ b/py/basicifstatements/challenge1.py @@ -0,0 +1,10 @@ +# Question: Ask the user for their age. If they are 18 or older tell them “You can vote”. + +# Ask the user for their age +age = int(input("Enter your age: ")) + +# Check if the user is 18 or older +if age >= 18: + print("You can vote") +else: + print("You cannot vote yet") \ No newline at end of file diff --git a/py/ifelsestatements/challenge3.py b/py/ifelsestatements/challenge3.py new file mode 100644 index 0000000..91613ff --- /dev/null +++ b/py/ifelsestatements/challenge3.py @@ -0,0 +1,13 @@ +# Ask the user to input two numbers +num1 = float(input("Enter the first number: ")) +num2 = float(input("Enter the second number: ")) + +# Calculate the average +answer = (num1 + num2) / 2 + +# Check if the average is less than 100 +if answer < 100: + print("The average is", answer) + +# Print "Goodbye" at the end +print("Goodbye")