From 3ba9913aac1eb323e48c8b0b66978465f2390e14 Mon Sep 17 00:00:00 2001 From: N0tstgr Date: Tue, 22 Jul 2025 18:01:21 +0530 Subject: [PATCH] chapter3 --- 01_introstring.py | 9 +++++++++ 02_negative_slicing.py | 6 ++++++ 03_str_functions.py | 13 +++++++++++++ 04_escape_seq.py | 3 +++ pythonL | 1 + 5 files changed, 32 insertions(+) create mode 100644 01_introstring.py create mode 100644 02_negative_slicing.py create mode 100644 03_str_functions.py create mode 100644 04_escape_seq.py create mode 160000 pythonL diff --git a/01_introstring.py b/01_introstring.py new file mode 100644 index 00000000..9448c944 --- /dev/null +++ b/01_introstring.py @@ -0,0 +1,9 @@ +name = "vikash" +nameshort = name[0:3] #start from index 0 all the way till 3 (excluding 3) + + +# nameshort = len(name) +character1 = name[1] +print(character1) +print(nameshort) + diff --git a/02_negative_slicing.py b/02_negative_slicing.py new file mode 100644 index 00000000..92ec8ae3 --- /dev/null +++ b/02_negative_slicing.py @@ -0,0 +1,6 @@ +name = "vikashthetrillionaire" +print(name[0:7]) +print(name[-8: -1]) +print(name[:4]) # is same is [0:4] +print(name[7:]) # is same as [7: end] +#space means length diff --git a/03_str_functions.py b/03_str_functions.py new file mode 100644 index 00000000..0a52e76e --- /dev/null +++ b/03_str_functions.py @@ -0,0 +1,13 @@ +name = "Vikash the trillionaire" +print(len(name)) +print(name.endswith("aire")) +print(name.startswith("vika")) +print(name.capitalize()) +# print(name.small()) +print(name.lower()) +print(name.upper()) +print(name.title()) +print("\n") +print(name.find("the")) +print(name.lstrip()) +print(name.rstrip()) \ No newline at end of file diff --git a/04_escape_seq.py b/04_escape_seq.py new file mode 100644 index 00000000..7aa2e546 --- /dev/null +++ b/04_escape_seq.py @@ -0,0 +1,3 @@ +a = "vikash is a handsome leader \n but \t \"not" +a = 'vikash is a handsome leader \n but \t \'not' +print(a) diff --git a/pythonL b/pythonL new file mode 160000 index 00000000..894b4d95 --- /dev/null +++ b/pythonL @@ -0,0 +1 @@ +Subproject commit 894b4d95c14525532bd158d7a3e7327dcd0192ce