Have you ever tried to learn models by going through Django Docs? Did you leave with answers, or with even more questions?
Lovely Article on web scraping with python
Do you ever find yourself in a situation where you need to get information out of a website that conveniently doesn’t have an export option…
Its Been a while since I dropped an original post here. Lately, I’ve been sharing tech related articles am interested in as opposed to actually writing one. During this period, I’ve been trying to build up my Backend programming skills. it hasn’t been an easy ride so far. Started off with Php and the laravel framework but I immediately realized that am no good at Php. The framework was amazing to use but I just found it hard to comprehend the Php bit. (A solid understanding of Php is actually a prerequisite for using the framework.)
The time spent trying to study Php helped me realize that I needed to strengthen my core computer science skills. So, I’ve decided to focus on fundamental programming concepts such as Object oriented programming, algorithms, regular expressions, classes, methods etc. Once am comfortable with these fundamental programming concepts, I can get back to working with Backend frameworks like laravel and Django.
On my quest to rebuild these fundamental programming skills, i have picked a keen interest in the python programming language. Unlike PHP, i find it easy to understand the language and the concepts I need to brush up on. So, moving forward, I will use this blog to document my progress on the python programming language. I will share the exercise questions and my solutions to those questions as i encounter them in the various textbooks I’ve decided to read.
I hope this will be the beginning of a very exciting journey into python programming.
CURRENT BOOK AM READING: PYTHON PROGRAMMING (a Free book available here)
Exercises on Lists
Q1. Use a list comprehension to construct the list [’ab’, ’ac’, ’ad’, ’bb’, ’bc’, ’bd’].
item = [x + y for x in 'ab' for y in 'bcd'] print(item)
['ab', 'ac', 'ad', 'bb', 'bc', 'bd']
Q2. Use a slice on the above list to construct the list [’ab’, ’ad’, ’bc’].
item2 = item[::2] print(item2)
['ab', 'ad', 'bc']
Q3. Use a list comprehension to construct the list [’1a’, ’2a’, ’3a’, ’4a’].
item3 = [x + y for x in '1234' for y in 'a'] print(item3)
['1a', '2a', '3a', '4a']
Q4. Simultaneously remove the element ’2a’ from the above list and print it.
Q5. Copy the above list and add ’2a’ back into the list such that the original is still missing it.
print('item3 popped: ', item3)
item3 popped: ['1a', '3a', '4a']
item4 = item3[:] print('item4 as copy of item3 popped: ', item4)
item4 as copy of item3 popped: ['1a', '3a', '4a']
item4.append('2a') print('item4 with new item added: ', item4)
item4 with new item added: ['1a', '3a', '4a', '2a']
print('item3 still popped: ', item3)
item3 still popped: ['1a', '3a', '4a']
Q6. Use a list comprehension to construct the list [’abe’, ’abf ’, ’ace’, ’acf ’, ’ade’, ’bbe’, ’bbf ’, ’bce’, ’bcf ’, ’bde’, ’bdf ’]
item5 = [x+y+z for x in 'ab' for y in 'bcd' for z in 'ef'] print('item5: ', item5)
['abe', 'abf', 'ace', 'acf', 'ade', 'adf', 'bbe', 'bbf', 'bce', 'bcf', 'bde', 'bdf']