From 3616045000624e049a0dcba43883182775b690c3 Mon Sep 17 00:00:00 2001 From: brendaweles <160772586+brendaweles@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:18:02 -0400 Subject: [PATCH] Revert "Sample code for the article on the string data type" --- python-string/README.md | 3 --- python-string/concatenation.py | 3 --- python-string/formatting copy.py | 5 ----- python-string/formatting.py | 33 -------------------------------- python-string/person.py | 17 ---------------- python-string/regexes.py | 12 ------------ python-string/table.py | 18 ----------------- 7 files changed, 91 deletions(-) delete mode 100644 python-string/README.md delete mode 100644 python-string/concatenation.py delete mode 100644 python-string/formatting copy.py delete mode 100644 python-string/formatting.py delete mode 100644 python-string/person.py delete mode 100644 python-string/regexes.py delete mode 100644 python-string/table.py diff --git a/python-string/README.md b/python-string/README.md deleted file mode 100644 index e102c575cb..0000000000 --- a/python-string/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Strings and Character Data in Python - -This folder provides the code examples for the Real Python tutorial [Strings and Character Data in Python](https://realpython.com/python-string/). diff --git a/python-string/concatenation.py b/python-string/concatenation.py deleted file mode 100644 index 21c33ddbae..0000000000 --- a/python-string/concatenation.py +++ /dev/null @@ -1,3 +0,0 @@ -greeting = "Hello" -name = "Pythonista" -print(greeting + ", " + name + "!!!") diff --git a/python-string/formatting copy.py b/python-string/formatting copy.py deleted file mode 100644 index 141acb9138..0000000000 --- a/python-string/formatting copy.py +++ /dev/null @@ -1,5 +0,0 @@ -from datetime import datetime - -print(format(1000000, ",.2f")) # Thousand separators -print(format("Header", "=^30")) # Centered and filled -print(format(datetime.now(), "%a %b %d, %Y")) # Date diff --git a/python-string/formatting.py b/python-string/formatting.py deleted file mode 100644 index c9e12d81ca..0000000000 --- a/python-string/formatting.py +++ /dev/null @@ -1,33 +0,0 @@ -debit = 300.00 -credit = 450.00 - -template = """ -Account Report -Credit: ${credit:.2f} -Debit: -${debit:.2f} -________________ -Balance: ${balance:.2f}""" - -print( - template.format( - credit=credit, - debit=debit, - balance=credit - debit, - ) -) - -template = """ -Account Report -Credit: $%(credit).2f -Debit: -$%(debit).2f -________________ -Balance: $%(balance).2f""" - -print( - template - % { - "credit": credit, - "debit": debit, - "balance": credit - debit, - } -) diff --git a/python-string/person.py b/python-string/person.py deleted file mode 100644 index e5a56797ec..0000000000 --- a/python-string/person.py +++ /dev/null @@ -1,17 +0,0 @@ -class Person: - def __init__(self, name, age): - self.name = name - self.age = age - - def __repr__(self): - return f"{type(self).__name__}(name='{self.name}', age={self.age})" - - def __str__(self): - return f"I'm {self.name}, and I'm {self.age} years old." - - -john = Person("John Doe", 35) - -print(repr(john)) - -print(str(john)) diff --git a/python-string/regexes.py b/python-string/regexes.py deleted file mode 100644 index 0e26e4ddbd..0000000000 --- a/python-string/regexes.py +++ /dev/null @@ -1,12 +0,0 @@ -import re - -pattern = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b" - -regex = re.compile(pattern) - -text = """ - Please contact us at support@example.com - or sales@example.com for further information. -""" - -print(regex.findall(text)) diff --git a/python-string/table.py b/python-string/table.py deleted file mode 100644 index acb56d2cc8..0000000000 --- a/python-string/table.py +++ /dev/null @@ -1,18 +0,0 @@ -def display_table(data, headers): - max_len = max(len(header) for header in headers) - print("|".join(header.ljust(max_len) for header in headers)) - sep = "-" * max_len - print("|".join(sep for _ in headers)) - for row in data: - print("|".join(header.ljust(max_len) for header in row)) - - -data = [ - ["Alice", "25", "Python Developer"], - ["Bob", "30", "Web Designer"], - ["Charlie", "35", "Team Lead"], -] - -headers = ["Name", "Age", "Job Title"] - -display_table(data, headers)