100 Days of Code: Python Developer Challenge 2023 | Day 7
Hi guys.
We have completed the sixth day of the challenge. To repeat or revise the sixth day:
Let’s start the exercises on the seventh day!
Exercise1:
The following codes are given:
- code1 = ‘Python3.3.11’
- code2 = ‘PythonLoVe_U’
- code3 = ‘P-y-t-h-o-n’
- code4 = ‘Python3LoveU’
Using the appropriate method, check whether the codes consist only of alphanumeric characters (numbers + letters). Print the result to the consol.
code1 = 'Python3.3.11'
code2 = 'PythonLoVe_U'
code3 = 'P-y-t-h-o-n'
code4 = 'Python3LoveU'
print(f'code1: {code1.isalnum()}')
print(f'code2: {code2.isalnum()}')
print(f'code3: {code3.isalnum()}')
print(f'code4: {code4.isalnum()}')
If we run this code, we will see the following output:
code1: False
code2: False
code3: False
code4: True
Exercise2:
The following text is given:
- text = ‘100 Days of Code: Python Developer Challenge 2023 | Day 7’
Using the appropriate method convert all letters to lowercase. Print the result to the console.
text = '100 Days of Code: Python Developer Challenge 2023 | Day 7'
print(text.lower())
If we run this code, we will see the following output:
100 days of code: python developer challenge 2023 | day 7
Exercise3:
The following text is given:
- text = ‘100-Days-of-Code:-Python-Developer-Challenge-2023 | Day-7‘
Using the appropriate method replace the dashes with a space. Print the result to the console.
text = '100-Days-of-Code:-Python-Developer-Challenge-2023 | Day-7'
print(text.replace('-', ' '))
If we run this code, we will see the following output:
100 Days of Code: Python Developer Challenge 2023 | Day 7
We solved 3 beautiful examples for the 7. day. Don’t forget to follow me for other nice examples!
Google Colab link with questions and solutions:
If you have solved the questions in different ways, you can share it with us.
See you soon!