Skip to content

Commit ee5715b

Browse files
committed
Updated Python Projects with 2 new beginner projects.
1 parent 0a401e6 commit ee5715b

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

Beginner/8_text_encryption.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Get the user's input text
2+
text = input("Enter the text you want to encrypt: ")
3+
4+
# Get the user's encryption password
5+
password = input("Enter the password to encrypt the text: ")
6+
7+
# Encrypt the text using Caesar cipher
8+
encrypted_text = ""
9+
for char in text:
10+
encrypted_text += chr(ord(char) + len(password))
11+
12+
# Print the encrypted text
13+
print("Encrypted text:", encrypted_text)
14+
15+
decrypt = input("Do you want to decrypt the text? (yes/no): ")
16+
if decrypt == "yes":
17+
# Decrypt the text using Caesar cipher
18+
decrypted_text = ""
19+
for char in encrypted_text:
20+
decrypted_text += chr(ord(char) - len(password))
21+
22+
# Print the decrypted text
23+
print("Decrypted text:", decrypted_text)

Beginner/9_countdown_timer.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from time import sleep
2+
3+
# Prompt the user for a time to countdown from
4+
time = input("Enter the time to countdown from (MM:SS): ")
5+
6+
# Check the format of the input
7+
if len(time) != 5 or time[2] != ":":
8+
print("Invalid time format")
9+
exit()
10+
11+
# Extract the minutes and seconds
12+
minutes = int(time[:2])
13+
seconds = int(time[3:])
14+
total_seconds = minutes * 60 + seconds
15+
16+
# Countdown
17+
for i in range(total_seconds, 0, -1):
18+
print(f"{i//60:02}:{i%60:02}")
19+
sleep(1)
20+
21+
print("00:00")
22+
print("Time's up!")

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,76 @@ These projects are ideal for those new to Python. Each project includes a descri
253253

254254
</details>
255255

256+
### 8. Text Encryption
257+
- **Description**: Create a text encryption function with decryption as well.
258+
259+
- **Solution**: https://github.com/Infinitode/Python-Projects/blob/main/Beginner/8_text_encryption.py
260+
261+
- **Steps**:
262+
1. Prompt the user for text and a password (to be used for encryption).
263+
2. Encrypt the text.
264+
3. Decrypt the text.
265+
4. Display the results.
266+
267+
- **Tips:**
268+
269+
</summary>
270+
<details><summary>Tip 1:</summary>
271+
272+
Use `input()` for input.
273+
274+
</details>
275+
<details><summary>Tip 2:</summary>
276+
277+
Use simple encryption methods like Caesar cipher.
278+
279+
</details>
280+
<details><summary>Tip 3:</summary>
281+
282+
Store the password in a variable to use it later during decryption.
283+
284+
</details>
285+
<details><summary>Tip 4:</summary>
286+
287+
Print out the results using `print()`.
288+
289+
</details>
290+
291+
### 9. Countdown Timer
292+
- **Description**: Create a countdown timer for seconds and minutes.
293+
294+
- **Solution**: https://github.com/Infinitode/Python-Projects/blob/main/Beginner/9_countdown_timer.py
295+
296+
- **Steps**:
297+
1. Prompt the user for a time, in a specific format.
298+
2. Extract information from the provided time.
299+
3. Countdown.
300+
4. Display the results.
301+
302+
- **Tips:**
303+
304+
</summary>
305+
<details><summary>Tip 1:</summary>
306+
307+
Use `input()` for input.
308+
309+
</details>
310+
<details><summary>Tip 2:</summary>
311+
312+
Use simple string manipulation techniques to get the minutes and seconds from the provided time.
313+
314+
</details>
315+
<details><summary>Tip 3:</summary>
316+
317+
Use `time.sleep(1)` to count down in seconds.
318+
319+
</details>
320+
<details><summary>Tip 4:</summary>
321+
322+
Print out the results using `print()`.
323+
324+
</details>
325+
256326
> [!NOTE]
257327
> Working code solutions are in the `/Beginner` folder.
258328

0 commit comments

Comments
 (0)