Skip to content

Commit 43ca674

Browse files
committed
update Basic_Calculator.py and Password_Generator.py
1 parent fbcf8a8 commit 43ca674

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Basic-Calculator/Basic_Calculator.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@
33
# Description: A simple command-line calculator that performs addition, subtraction, multiplication, and division.
44

55
def add(x, y):
6-
#Return the sum of x and y.
6+
# Return the sum of x and y.
77
return x + y
88

9+
910
def subtract(x, y):
10-
#Return the difference between x and y.
11+
# Return the difference between x and y.
1112
return x - y
1213

14+
1315
def multiply(x, y):
14-
#Return the product of x and y.
16+
# Return the product of x and y.
1517
return x * y
1618

19+
1720
def divide(x, y):
18-
#Return the quotient of x divided by y. Handles division by zero.
21+
# Return the quotient of x divided by y. Handles division by zero.
1922
if y == 0:
2023
return "Error! Division by zero."
2124
else:
2225
return x / y
2326

27+
2428
print("Welcome to the Basic Calculator!")
2529
print("Select operation:")
2630
print("1. Addition")

Password-Generator/Password_Generator.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import random
66
import string
77

8+
89
def generate_password(length):
9-
#Generate a random password of a specified length between 8 and 16 characters.
10+
# Generate a random password of a specified length between 8 and 16 characters.
1011
if length < 8 or length > 16:
1112
return "Password length must be between 8 and 16 characters."
1213

@@ -33,10 +34,11 @@ def generate_password(length):
3334

3435
# Shuffle the list to ensure random order
3536
random.shuffle(password)
36-
37+
3738
# Convert list to string
3839
return ''.join(password)
3940

41+
4042
print("Welcome to the Password Generator!")
4143
length = int(input("Enter the desired password length (8 to 16): "))
4244
print(f"Generated password: {generate_password(length)}")

0 commit comments

Comments
 (0)