Skip to content

Commit 1adbbcb

Browse files
committed
Added 3 new scripts
1 parent ca0b104 commit 1adbbcb

5 files changed

Lines changed: 104 additions & 0 deletions

File tree

Guess the Number Game/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div align="center">
2+
3+
# Guess the Number Game
4+
5+
</div>
6+
7+
### Description:
8+
This Python script implements a simple "Guess the Number" game where the player has to guess a randomly generated number between 1 and 100. The script provides feedback to the player if their guess is too high or too low and counts the number of attempts until the correct number is guessed.
9+
10+
### How to Use:
11+
1. Run the script in a Python environment.
12+
2. Follow the prompts to guess the number.
13+
3. Keep guessing until you correctly identify the number.

Simple Calculator/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<div align="center">
2+
3+
# Simple Calculator
4+
5+
</div>
6+
7+
### Description:
8+
This Python script implements a basic calculator with addition, subtraction, multiplication, and division operations. It presents a menu for the user to select the operation they want to perform and prompts the user to input two numbers. After inputting the numbers, it performs the selected operation and displays the result.
9+
10+
### How to Use:
11+
1. Run the script in a Python environment.
12+
2. Choose the operation: Add, Subtract, Multiply, or Divide.
13+
3. Enter the first number when prompted.
14+
4. Enter the second number when prompted.
15+
5. The script will display the result of the chosen operation.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
def add(x, y):
2+
return x + y
3+
4+
5+
def subtract(x, y):
6+
return x - y
7+
8+
9+
def multiply(x, y):
10+
return x * y
11+
12+
13+
def divide(x, y):
14+
if y == 0:
15+
return "Cannot divide by zero!"
16+
return x / y
17+
18+
19+
def calculator():
20+
print("1. Add")
21+
print("2. Subtract")
22+
print("3. Multiply")
23+
print("4. Divide")
24+
choice = int(input("Enter your choice (1/2/3/4): "))
25+
num1 = float(input("Enter first number: "))
26+
num2 = float(input("Enter second number: "))
27+
if choice == 1:
28+
print("Result:", add(num1, num2))
29+
elif choice == 2:
30+
print("Result:", subtract(num1, num2))
31+
elif choice == 3:
32+
print("Result:", multiply(num1, num2))
33+
elif choice == 4:
34+
print("Result:", divide(num1, num2))
35+
else:
36+
print("Invalid choice!")
37+
38+
39+
calculator()

Temperature Converter/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<div align="center">
2+
3+
# Temperature Converter
4+
5+
</div>
6+
7+
### Description:
8+
This Python script includes functions to convert temperatures between Celsius and Fahrenheit. It provides a menu for the user to select the conversion they want to perform and prompts the user to input the temperature value. After inputting the temperature, it calculates and displays the converted value.
9+
10+
### How to Use:
11+
1. Run the script in a Python environment.
12+
2. Choose the conversion type: Celsius to Fahrenheit or Fahrenheit to Celsius.
13+
3. Enter the temperature value when prompted.
14+
4. The script will display the converted temperature.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def celsius_to_fahrenheit(celsius):
2+
return (celsius * 9/5) + 32
3+
4+
5+
def fahrenheit_to_celsius(fahrenheit):
6+
return (fahrenheit - 32) * 5/9
7+
8+
9+
def temperature_converter():
10+
print("1. Celsius to Fahrenheit")
11+
print("2. Fahrenheit to Celsius")
12+
choice = int(input("Enter your choice (1 or 2): "))
13+
if choice == 1:
14+
celsius = float(input("Enter temperature in Celsius: "))
15+
print(f"{celsius}°C is equal to {celsius_to_fahrenheit(celsius)}°F.")
16+
elif choice == 2:
17+
fahrenheit = float(input("Enter temperature in Fahrenheit: "))
18+
print(f"{fahrenheit}°F is equal to {fahrenheit_to_celsius(fahrenheit)}°C.")
19+
else:
20+
print("Invalid choice!")
21+
22+
23+
temperature_converter()

0 commit comments

Comments
 (0)