Skip to content

kinga-marszalkowska/10-Days-Coding-Challenge-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

10 day coding challenge with Python

This repository contains my solutions for the 10 day winter-break coding challenge. Each day there was a problem to solve. The idea of the challenge is to learn something new and adapt the problem to own programming skills.

Event link: https://www.facebook.com/events/843253696243420?active_tab=about

What I learned during the challenge?

• Discovered a wide range of Python modules,

• Got familliar with many different APIs, processing requests and using the data in the code,

• Improved my knowledge of modules previously known to me,

• Coding regularily, the challenge gave me a routine to follow and problems to solve, which I often extended to make more challenging.

• Became more fluent with reading documentation.

📖 Table of contents:

• Day 1: Palindromes, web scraping

• Day 2: API, openpyxl

• Day 3: Automatic email sending

• Day 4: BMI calculator

• Day 5: Movie API

• Day 6: Image resizer

• Day 7: Password_generator

• Day 8: Geo locator

• Day 9: Library

• Day 10: Challenge recap

🧐 Day 1: Palindromes, web scraping

❗ Requirements (from prompt):

  1. Check if an inputted word is a palindrome, display adequate message.

  2. Run a webpage that displays anagrams of an inputted word.

↗️ My extension:

Use selenium library to web scrape in search for data which I display in the terminal.

🧠 Learned today:

• web scraping basics, finding specific tags and classes on a page

• selenium library for Python

🔗 Helpful links: https://selenium-python.readthedocs.io/ https://www.w3schools.com/python/python_regex.asp https://sites.google.com/a/chromium.org/chromedriver/downloads

⛅ Day 2: API, openpyxl

❗ Requirements (from prompt):

  1. Display date, time, day of the week, temperature in a given city. Use https://rapidapi.com/commu.../api/open-weather-map/endpoints

  2. Display a random quote https://type.fit/api/quotes

  3. Use datetime and request libraries

↗️ My extensions:

Create a calendar card in excel with data from the weather API.

Error messages for requests with error codes other than 200.

🧠 Learned today:

• a few useful options for editing spreadsheet (merging, coloring cells, changing font, style)

• method for calculations on dates (timedelta), strftime for date formatting

🔗 Helpful links: https://openweathermap.org/current https://rapidapi.com/community/api/open-weather-map/ https://requests.readthedocs.io/en/master/user/quickstart/#response-content

📧 Day 3: Automatic email sending

❗ Requirements (from prompt):

  1. Send emails to people from a mailing list (in csv or xls), with a message and an image

  2. Secure program for edge cases (no image file, no mailing list etc.)

↗️ My extensions:

I used a function for getting random quotes from API (from Day 2) as a message content.

I used bing_image_downloader to download an image that represents the quote.

🧠 Learned today:

• smtplib for sending emails

🔗 Helpful links:

https://pypi.org/project/bing-image-downloader/ https://docs.python.org/3/library/email.examples.html https://www.youtube.com/watch?v=m9ojKEBYCvQ

⚖️ Day 4: BMI calculator

❗ Requirements (from prompt):

  1. Write a program that, given weight in kgs and height in cms calculates BMI.

  2. Then, a program at random chooses a sport activity and time (less or equal to the one given by user).

  3. Create a training plan in a text file for the next 7 days.

↗️ My extensions:

Instead of if-else statements for BMI, I used a map (keys: description, values: smallest and largest value of the index for this category)

Time of activity selected at random, min time is the value of index for given person (people with higher index ought to exercise more) max time is specified by user

In any case time of the activity should be no shorter than 10 minutes.

🧠 Learned today:

• "string".format() - formatting string to include values in it, instead of using the + operator many times

🎞️ Day 5: Movie API

❗ Requirements (from prompt):

  1. Find info about all the parts of movie that a user searches.

↗️ My extensions:

Used a library terminaltables to display information.

🧠 Learned today:

• A new, useful API: https://rapidapi.com/apidojo/api/imdb8/endpoints

🖼️ Day 6: Image resizer

❗ Requirements (from prompt):

  1. Compress image

  2. Calculate saved space

↗️ My extensions:

Used a tkinter library to select origin and destination folder.

🧠 Learned today:

• Basics of Pillow library.

• How to use tkinter directory selection.

🔗 Helpful link:

https://auth0.com/blog/image-processing-in-python-with-pillow/

🔒 Day 7: Password generator

❗ Requirements (from prompt):

  1. Generate password of a specified length.

↗️ My extensions:

Used Datamuse API to find words that will help the user better remember their new password.

For letters - find words that start with a given letter. For special characters - find words that sound familliar or rhyme with, ex. brackets rhymes with jackets.

These words than can be used to create a story / association to quickly remember secure and complicated password.

🌏 Day 8: Geo locator

❗ Requirements (from prompt):

  1. Calculate geo location between your location and any given.

↗️ My extensions:

Used geocoder to get current location.

🧠 Learned today:

• How to get current location with geocoder

🔗 Helpful links:

https://pl.wikibooks.org/.../Astrono.../Odleg%C5%82o%C5%9Bci

https://rapidapi.com/trueway/api/trueway-geocoding

📚 Day 9: Library

❗ Requirements (from prompt):

  1. Use Biblioteka Narodowa's (the National Library) API to get all books of a chosen author in a list.

↗️ My extensions:

Used termitables to display the book's title, year of publishing and genre.

🧠 Learned today:

• Got more familliar with reading documentation.

🔗 Helpful links:

http://data.bn.org.pl/?fbclid=IwAR0dG5T7JNimkjHp3NIBOAfYwZo2PEgB2_fY6hvIMJhNRZ0qop4QTUb4Ec4

Day 10: Challenge recap

❗ Requirements (from prompt):

  1. Calculate the total number of lines of code written in this challenge.

  2. Calculate the number of unique words in all files.

  3. Calculate the number of keywords.

  4. List all the modules used.

↗️ My extensions:

For listing the modules, I found the lines in code that contained "import" and "from" keywords and got only the modules' names.

🧠 Learned today:

• Discovered keywords library

• Got more familliar with reading documentation.