From 36f7b0e4df642c9d633b8ce39ea77ef4672e5862 Mon Sep 17 00:00:00 2001 From: prince-dev41 Date: Mon, 30 Jun 2025 11:51:11 +0100 Subject: [PATCH 1/2] fix: corrected typos and formatting in Day 4 --- .../04_Day_Strings/day_4_20250629200723.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250629212247.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250629222502.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250629222503.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250629222505.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250629222649.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250630090926.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250630090941.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250630090943.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250630091848.py | 247 ++++++++++++++++++ .../04_Day_Strings/day_4_20250630091849.py | 247 ++++++++++++++++++ 01_Day_Introduction/helloworld.py | 1 - 04_Day_Strings/day_4.py | 5 +- data/stop_words.py | 3 +- 14 files changed, 2720 insertions(+), 6 deletions(-) create mode 100644 .history/04_Day_Strings/day_4_20250629200723.py create mode 100644 .history/04_Day_Strings/day_4_20250629212247.py create mode 100644 .history/04_Day_Strings/day_4_20250629222502.py create mode 100644 .history/04_Day_Strings/day_4_20250629222503.py create mode 100644 .history/04_Day_Strings/day_4_20250629222505.py create mode 100644 .history/04_Day_Strings/day_4_20250629222649.py create mode 100644 .history/04_Day_Strings/day_4_20250630090926.py create mode 100644 .history/04_Day_Strings/day_4_20250630090941.py create mode 100644 .history/04_Day_Strings/day_4_20250630090943.py create mode 100644 .history/04_Day_Strings/day_4_20250630091848.py create mode 100644 .history/04_Day_Strings/day_4_20250630091849.py diff --git a/.history/04_Day_Strings/day_4_20250629200723.py b/.history/04_Day_Strings/day_4_20250629200723.py new file mode 100644 index 000000000..ab461785f --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629200723.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.digit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629212247.py b/.history/04_Day_Strings/day_4_20250629212247.py new file mode 100644 index 000000000..b447550b7 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629212247.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222502.py b/.history/04_Day_Strings/day_4_20250629222502.py new file mode 100644 index 000000000..d9182a31a --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629222502.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print("hechallenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222503.py b/.history/04_Day_Strings/day_4_20250629222503.py new file mode 100644 index 000000000..e6e8ef530 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629222503.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print("he"challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222505.py b/.history/04_Day_Strings/day_4_20250629222505.py new file mode 100644 index 000000000..117003d8a --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629222505.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print("he",challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222649.py b/.history/04_Day_Strings/day_4_20250629222649.py new file mode 100644 index 000000000..b447550b7 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250629222649.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090926.py b/.history/04_Day_Strings/day_4_20250630090926.py new file mode 100644 index 000000000..999fe65aa --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250630090926.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print("ed",challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090941.py b/.history/04_Day_Strings/day_4_20250630090941.py new file mode 100644 index 000000000..b447550b7 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250630090941.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090943.py b/.history/04_Day_Strings/day_4_20250630090943.py new file mode 100644 index 000000000..fe7797cba --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250630090943.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print("ed",challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630091848.py b/.history/04_Day_Strings/day_4_20250630091848.py new file mode 100644 index 000000000..7ccea3663 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250630091848.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print("challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630091849.py b/.history/04_Day_Strings/day_4_20250630091849.py new file mode 100644 index 000000000..b447550b7 --- /dev/null +++ b/.history/04_Day_Strings/day_4_20250630091849.py @@ -0,0 +1,247 @@ + +# Single line String +letter = 'P' # A string could be a single character or a bunch of texts +print(letter) # P +print(len(letter)) # 1 +greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" +print(greeting) # Hello, World! +print(len(greeting)) # 13 +sentence = "I hope you are enjoying 30 days of python challenge" +print(sentence) + +# Multiline String +multiline_string = '''I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.''' +print(multiline_string) +# Another way of doing the same thing +multiline_string = """I am a teacher and enjoy teaching. +I didn't find anything as rewarding as empowering people. +That is why I created 30 days of python.""" +print(multiline_string) + +# String Concatenation +first_name = 'Asabeneh' +last_name = 'Yetayeh' +space = ' ' +full_name = first_name + space + last_name +print(full_name) # Asabeneh Yetayeh +# Checking length of a string using len() builtin function +print(len(first_name)) # 8 +print(len(last_name)) # 7 +print(len(first_name) > len(last_name)) # True +print(len(full_name)) # 15 + +#### Unpacking characters +language = 'Python' +a,b,c,d,e,f = language # unpacking sequence characters into variables +print(a) # P +print(b) # y +print(c) # t +print(d) # h +print(e) # o +print(f) # n + +# Accessing characters in strings by index +language = 'Python' +first_letter = language[0] +print(first_letter) # P +second_letter = language[1] +print(second_letter) # y +last_index = len(language) - 1 +last_letter = language[last_index] +print(last_letter) # n + +# If we want to start from right end we can use negative indexing. -1 is the last index +language = 'Python' +last_letter = language[-1] +print(last_letter) # n +second_last = language[-2] +print(second_last) # o + +# Slicing + +language = 'Python' +first_three = language[0:3] # starts at zero index and up to 3 but not include 3 +last_three = language[3:6] +print(last_three) # hon +# Another way +last_three = language[-3:] +print(last_three) # hon +last_three = language[3:] +print(last_three) # hon + +# Skipping character while splitting Python strings +language = 'Python' +pto = language[0:6:2] # +print(pto) # pto + +# Escape sequence +print('I hope every one enjoying the python challenge.\nDo you ?') # line break +print('Days\tTopics\tExercises') +print('Day 1\t3\t5') +print('Day 2\t3\t5') +print('Day 3\t3\t5') +print('Day 4\t3\t5') +print('This is a back slash symbol (\\)') # To write a back slash +print('In every programming language it starts with \"Hello, World!\"') + +## String Methods +# capitalize(): Converts the first character the string to Capital Letter + +challenge = 'thirty days of python' +print(challenge.capitalize()) # 'Thirty days of python' + +# count(): returns occurrences of substring in string, count(substring, start=.., end=..) + +challenge = 'thirty days of python' +print(challenge.count('y')) # 3 +print(challenge.count('y', 7, 14)) # 1 +print(challenge.count('th')) # 2` + +# endswith(): Checks if a string ends with a specified ending + +challenge = 'thirty days of python' +print(challenge.endswith('on')) # True +print(challenge.endswith('tion')) # False + +# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument + +challenge = 'thirty\tdays\tof\tpython' +print(challenge.expandtabs()) # 'thirty days of python' +print(challenge.expandtabs(10)) # 'thirty days of python' + +# find(): Returns the index of first occurrence of substring + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# format() formats string into nicer output +first_name = 'Asabeneh' +last_name = 'Yetayeh' +job = 'teacher' +country = 'Finland' +sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) +print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. + +radius = 10 +pi = 3.14 +area = pi # radius ## 2 +result = 'The area of circle with {} is {}'.format(str(radius), str(area)) +print(result) # The area of circle with 10 is 314.0 + +# index(): Returns the index of substring +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isalnum(): Checks alphanumeric character + +challenge = 'ThirtyDaysPython' +print(challenge.isalnum()) # True + +challenge = '30DaysPython' +print(challenge.isalnum()) # True + +challenge = 'thirty days of python' +print(challenge.isalnum()) # False + +challenge = 'thirty days of python 2019' +print(challenge.isalnum()) # False + +# isalpha(): Checks if all characters are alphabets + +challenge = 'thirty days of python' +print(challenge.isalpha()) # True +num = '123' +print(num.isalpha()) # False + +# isdecimal(): Checks Decimal Characters + +challenge = 'thirty days of python' +print(challenge.find('y')) # 5 +print(challenge.find('th')) # 0 + +# isdigit(): Checks Digit Characters +challenge = 'Thirty' +print(challenge.isdigit()) # False +challenge = '30' +print(challenge.isdigit()) # True + +# isdecimal():Checks decimal characters + +num = '10' +print(num.isdecimal()) # True +num = '10.5' +print(num.isdecimal()) # False + + +# isidentifier():Checks for valid identifier means it check if a string is a valid variable name + +challenge = '30DaysOfPython' +print(challenge.isidentifier()) # False, because it starts with a number +challenge = 'thirty_days_of_python' +print(challenge.isidentifier()) # True + + +# islower():Checks if all alphabets in a string are lowercase + +challenge = 'thirty days of python' +print(challenge.islower()) # True +challenge = 'Thirty days of python' +print(challenge.islower()) # False + +# isupper(): returns if all characters are uppercase characters + +challenge = 'thirty days of python' +print(challenge.isupper()) # False +challenge = 'THIRTY DAYS OF PYTHON' +print(challenge.isupper()) # True + + +# isnumeric():Checks numeric characters + +num = '10' +print(num.isnumeric()) # True +print('ten'.isnumeric()) # False + +# join(): Returns a concatenated string + +web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] +result = '#, '.join(web_tech) +print(result) # 'HTML# CSS# JavaScript# React' + +# strip(): Removes both leading and trailing characters + +challenge = ' thirty days of python ' +print(challenge.strip('y')) # 5 + +# replace(): Replaces substring inside + +challenge = 'thirty days of python' +print(challenge.replace('python', 'coding')) # 'thirty days of coding' + +# split():Splits String from Left + +challenge = 'thirty days of python' +print(challenge.split()) # ['thirty', 'days', 'of', 'python'] + +# title(): Returns a Title Cased String + +challenge = 'thirty days of python' +print(challenge.title()) # Thirty Days Of Python + +# swapcase(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.swapcase()) # THIRTY DAYS OF PYTHON +challenge = 'Thirty Days Of Python' +print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON + +# startswith(): Checks if String Starts with the Specified String + +challenge = 'thirty days of python' +print(challenge.startswith('thirty')) # True +challenge = '30 days of python' +print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/01_Day_Introduction/helloworld.py b/01_Day_Introduction/helloworld.py index 9c5f92cdf..8dcc15a9f 100644 --- a/01_Day_Introduction/helloworld.py +++ b/01_Day_Introduction/helloworld.py @@ -8,7 +8,6 @@ print(3 ** 2) # exponential(**) print(3 % 2) # modulus(%) print(3 // 2) # Floor division operator(//) - # Checking data types print(type(10)) # Int diff --git a/04_Day_Strings/day_4.py b/04_Day_Strings/day_4.py index 28ddc2622..b447550b7 100644 --- a/04_Day_Strings/day_4.py +++ b/04_Day_Strings/day_4.py @@ -1,5 +1,5 @@ -# Single line comment +# Single line String letter = 'P' # A string could be a single character or a bunch of texts print(letter) # P print(len(letter)) # 1 @@ -164,11 +164,10 @@ print(challenge.find('th')) # 0 # isdigit(): Checks Digit Characters - challenge = 'Thirty' print(challenge.isdigit()) # False challenge = '30' -print(challenge.digit()) # True +print(challenge.isdigit()) # True # isdecimal():Checks decimal characters diff --git a/data/stop_words.py b/data/stop_words.py index deafc4a76..96d3b02e5 100644 --- a/data/stop_words.py +++ b/data/stop_words.py @@ -1,2 +1 @@ -stop_words = ['i','me','my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up','down', 'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn', "mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"] - +stop_words = ['i','me','my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up','down', 'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn', "mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"] \ No newline at end of file From 4a775b7dc88c275480e19944fc5c78cdc8268217 Mon Sep 17 00:00:00 2001 From: prince-dev41 Date: Mon, 30 Jun 2025 11:51:36 +0100 Subject: [PATCH 2/2] fix: corrected typos and formatting in Day 4 --- .../04_Day_Strings/day_4_20250629200723.py | 247 ------------------ .../04_Day_Strings/day_4_20250629212247.py | 247 ------------------ .../04_Day_Strings/day_4_20250629222502.py | 247 ------------------ .../04_Day_Strings/day_4_20250629222503.py | 247 ------------------ .../04_Day_Strings/day_4_20250629222505.py | 247 ------------------ .../04_Day_Strings/day_4_20250629222649.py | 247 ------------------ .../04_Day_Strings/day_4_20250630090926.py | 247 ------------------ .../04_Day_Strings/day_4_20250630090941.py | 247 ------------------ .../04_Day_Strings/day_4_20250630090943.py | 247 ------------------ .../04_Day_Strings/day_4_20250630091848.py | 247 ------------------ .../04_Day_Strings/day_4_20250630091849.py | 247 ------------------ 11 files changed, 2717 deletions(-) delete mode 100644 .history/04_Day_Strings/day_4_20250629200723.py delete mode 100644 .history/04_Day_Strings/day_4_20250629212247.py delete mode 100644 .history/04_Day_Strings/day_4_20250629222502.py delete mode 100644 .history/04_Day_Strings/day_4_20250629222503.py delete mode 100644 .history/04_Day_Strings/day_4_20250629222505.py delete mode 100644 .history/04_Day_Strings/day_4_20250629222649.py delete mode 100644 .history/04_Day_Strings/day_4_20250630090926.py delete mode 100644 .history/04_Day_Strings/day_4_20250630090941.py delete mode 100644 .history/04_Day_Strings/day_4_20250630090943.py delete mode 100644 .history/04_Day_Strings/day_4_20250630091848.py delete mode 100644 .history/04_Day_Strings/day_4_20250630091849.py diff --git a/.history/04_Day_Strings/day_4_20250629200723.py b/.history/04_Day_Strings/day_4_20250629200723.py deleted file mode 100644 index ab461785f..000000000 --- a/.history/04_Day_Strings/day_4_20250629200723.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.digit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629212247.py b/.history/04_Day_Strings/day_4_20250629212247.py deleted file mode 100644 index b447550b7..000000000 --- a/.history/04_Day_Strings/day_4_20250629212247.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222502.py b/.history/04_Day_Strings/day_4_20250629222502.py deleted file mode 100644 index d9182a31a..000000000 --- a/.history/04_Day_Strings/day_4_20250629222502.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print("hechallenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222503.py b/.history/04_Day_Strings/day_4_20250629222503.py deleted file mode 100644 index e6e8ef530..000000000 --- a/.history/04_Day_Strings/day_4_20250629222503.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print("he"challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222505.py b/.history/04_Day_Strings/day_4_20250629222505.py deleted file mode 100644 index 117003d8a..000000000 --- a/.history/04_Day_Strings/day_4_20250629222505.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print("he",challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250629222649.py b/.history/04_Day_Strings/day_4_20250629222649.py deleted file mode 100644 index b447550b7..000000000 --- a/.history/04_Day_Strings/day_4_20250629222649.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090926.py b/.history/04_Day_Strings/day_4_20250630090926.py deleted file mode 100644 index 999fe65aa..000000000 --- a/.history/04_Day_Strings/day_4_20250630090926.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print("ed",challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090941.py b/.history/04_Day_Strings/day_4_20250630090941.py deleted file mode 100644 index b447550b7..000000000 --- a/.history/04_Day_Strings/day_4_20250630090941.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630090943.py b/.history/04_Day_Strings/day_4_20250630090943.py deleted file mode 100644 index fe7797cba..000000000 --- a/.history/04_Day_Strings/day_4_20250630090943.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print("ed",challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630091848.py b/.history/04_Day_Strings/day_4_20250630091848.py deleted file mode 100644 index 7ccea3663..000000000 --- a/.history/04_Day_Strings/day_4_20250630091848.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print("challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file diff --git a/.history/04_Day_Strings/day_4_20250630091849.py b/.history/04_Day_Strings/day_4_20250630091849.py deleted file mode 100644 index b447550b7..000000000 --- a/.history/04_Day_Strings/day_4_20250630091849.py +++ /dev/null @@ -1,247 +0,0 @@ - -# Single line String -letter = 'P' # A string could be a single character or a bunch of texts -print(letter) # P -print(len(letter)) # 1 -greeting = 'Hello, World!' # String could be a single or double quote,"Hello, World!" -print(greeting) # Hello, World! -print(len(greeting)) # 13 -sentence = "I hope you are enjoying 30 days of python challenge" -print(sentence) - -# Multiline String -multiline_string = '''I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.''' -print(multiline_string) -# Another way of doing the same thing -multiline_string = """I am a teacher and enjoy teaching. -I didn't find anything as rewarding as empowering people. -That is why I created 30 days of python.""" -print(multiline_string) - -# String Concatenation -first_name = 'Asabeneh' -last_name = 'Yetayeh' -space = ' ' -full_name = first_name + space + last_name -print(full_name) # Asabeneh Yetayeh -# Checking length of a string using len() builtin function -print(len(first_name)) # 8 -print(len(last_name)) # 7 -print(len(first_name) > len(last_name)) # True -print(len(full_name)) # 15 - -#### Unpacking characters -language = 'Python' -a,b,c,d,e,f = language # unpacking sequence characters into variables -print(a) # P -print(b) # y -print(c) # t -print(d) # h -print(e) # o -print(f) # n - -# Accessing characters in strings by index -language = 'Python' -first_letter = language[0] -print(first_letter) # P -second_letter = language[1] -print(second_letter) # y -last_index = len(language) - 1 -last_letter = language[last_index] -print(last_letter) # n - -# If we want to start from right end we can use negative indexing. -1 is the last index -language = 'Python' -last_letter = language[-1] -print(last_letter) # n -second_last = language[-2] -print(second_last) # o - -# Slicing - -language = 'Python' -first_three = language[0:3] # starts at zero index and up to 3 but not include 3 -last_three = language[3:6] -print(last_three) # hon -# Another way -last_three = language[-3:] -print(last_three) # hon -last_three = language[3:] -print(last_three) # hon - -# Skipping character while splitting Python strings -language = 'Python' -pto = language[0:6:2] # -print(pto) # pto - -# Escape sequence -print('I hope every one enjoying the python challenge.\nDo you ?') # line break -print('Days\tTopics\tExercises') -print('Day 1\t3\t5') -print('Day 2\t3\t5') -print('Day 3\t3\t5') -print('Day 4\t3\t5') -print('This is a back slash symbol (\\)') # To write a back slash -print('In every programming language it starts with \"Hello, World!\"') - -## String Methods -# capitalize(): Converts the first character the string to Capital Letter - -challenge = 'thirty days of python' -print(challenge.capitalize()) # 'Thirty days of python' - -# count(): returns occurrences of substring in string, count(substring, start=.., end=..) - -challenge = 'thirty days of python' -print(challenge.count('y')) # 3 -print(challenge.count('y', 7, 14)) # 1 -print(challenge.count('th')) # 2` - -# endswith(): Checks if a string ends with a specified ending - -challenge = 'thirty days of python' -print(challenge.endswith('on')) # True -print(challenge.endswith('tion')) # False - -# expandtabs(): Replaces tab character with spaces, default tab size is 8. It takes tab size argument - -challenge = 'thirty\tdays\tof\tpython' -print(challenge.expandtabs()) # 'thirty days of python' -print(challenge.expandtabs(10)) # 'thirty days of python' - -# find(): Returns the index of first occurrence of substring - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# format() formats string into nicer output -first_name = 'Asabeneh' -last_name = 'Yetayeh' -job = 'teacher' -country = 'Finland' -sentence = 'I am {} {}. I am a {}. I live in {}.'.format(first_name, last_name, job, country) -print(sentence) # I am Asabeneh Yetayeh. I am a teacher. I live in Finland. - -radius = 10 -pi = 3.14 -area = pi # radius ## 2 -result = 'The area of circle with {} is {}'.format(str(radius), str(area)) -print(result) # The area of circle with 10 is 314.0 - -# index(): Returns the index of substring -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isalnum(): Checks alphanumeric character - -challenge = 'ThirtyDaysPython' -print(challenge.isalnum()) # True - -challenge = '30DaysPython' -print(challenge.isalnum()) # True - -challenge = 'thirty days of python' -print(challenge.isalnum()) # False - -challenge = 'thirty days of python 2019' -print(challenge.isalnum()) # False - -# isalpha(): Checks if all characters are alphabets - -challenge = 'thirty days of python' -print(challenge.isalpha()) # True -num = '123' -print(num.isalpha()) # False - -# isdecimal(): Checks Decimal Characters - -challenge = 'thirty days of python' -print(challenge.find('y')) # 5 -print(challenge.find('th')) # 0 - -# isdigit(): Checks Digit Characters -challenge = 'Thirty' -print(challenge.isdigit()) # False -challenge = '30' -print(challenge.isdigit()) # True - -# isdecimal():Checks decimal characters - -num = '10' -print(num.isdecimal()) # True -num = '10.5' -print(num.isdecimal()) # False - - -# isidentifier():Checks for valid identifier means it check if a string is a valid variable name - -challenge = '30DaysOfPython' -print(challenge.isidentifier()) # False, because it starts with a number -challenge = 'thirty_days_of_python' -print(challenge.isidentifier()) # True - - -# islower():Checks if all alphabets in a string are lowercase - -challenge = 'thirty days of python' -print(challenge.islower()) # True -challenge = 'Thirty days of python' -print(challenge.islower()) # False - -# isupper(): returns if all characters are uppercase characters - -challenge = 'thirty days of python' -print(challenge.isupper()) # False -challenge = 'THIRTY DAYS OF PYTHON' -print(challenge.isupper()) # True - - -# isnumeric():Checks numeric characters - -num = '10' -print(num.isnumeric()) # True -print('ten'.isnumeric()) # False - -# join(): Returns a concatenated string - -web_tech = ['HTML', 'CSS', 'JavaScript', 'React'] -result = '#, '.join(web_tech) -print(result) # 'HTML# CSS# JavaScript# React' - -# strip(): Removes both leading and trailing characters - -challenge = ' thirty days of python ' -print(challenge.strip('y')) # 5 - -# replace(): Replaces substring inside - -challenge = 'thirty days of python' -print(challenge.replace('python', 'coding')) # 'thirty days of coding' - -# split():Splits String from Left - -challenge = 'thirty days of python' -print(challenge.split()) # ['thirty', 'days', 'of', 'python'] - -# title(): Returns a Title Cased String - -challenge = 'thirty days of python' -print(challenge.title()) # Thirty Days Of Python - -# swapcase(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.swapcase()) # THIRTY DAYS OF PYTHON -challenge = 'Thirty Days Of Python' -print(challenge.swapcase()) # tHIRTY dAYS oF pYTHON - -# startswith(): Checks if String Starts with the Specified String - -challenge = 'thirty days of python' -print(challenge.startswith('thirty')) # True -challenge = '30 days of python' -print(challenge.startswith('thirty')) # False \ No newline at end of file