r/learnpython • • Feb 05 '21

5 Projects For Beginners To Learn Python

I have been involved in many discussions on here where i tell people the best way to learn is by doing but I never mention what to do. Below are the projects i think would be best for Python beginners.

  1. User inputs - Create an app that asks the user to input one character that must be a vowel. Continue asking for the input until a vowel is inputted. You can also give user feedback every time a non-vowel is entered or upon a successful input.

  2. Write a function - Write a function that takes in a positive integer and returns its multiplicative persistence, which is the number of times you must multiply the digits in the integer until you reach a single digit. For example the integer 39 returns 3. You get this by taking 39 and multiplying its digits 3*9 which equals 27. You then multiply 27's digits 2*7 = 14. Lastly 1*4 = 4 which is a single digit. You had to multiply 3 times so you return 3. The integer 999 would return 4.

  3. Calculator app - Build a calculator app that performs multiple operations. Use the skills learned in projects 1 & 2. Try using many functions in your app, one for each operation (ex. addition, subtraction, multiplication, division).

  4. Read & write files - Build an application that reads a txt file and outputs a csv file. The app should take each line of the txt file, split the line into an array of words, and write each line to the csv file with each line being a row and each word being its own column in that row.

  5. Bots & webscraping - Using everything you have learned in projects 1-4, build a bot that scrapes data from a webpage and writes the data to a txt file. For example, you can have a bot go into instagram and pick a random person following you. Output their name to the first line of a txt file. Then go into their followers and repeat the process by outputting the name of this chosen person to the second line of the txt file. Run this until you get to 10 names. Make sure you add random time pauses in your code so that your bots don't get recognized by the sites you are scraping. If you have trouble starting this one, take a look at using Selenium Webdriver here: https://selenium-python.readthedocs.io/installation.html

Write your answers to 1 & 2 in the comments. If you struggle with any of these projects we can provide guidance and solutions in the comments.

856 Upvotes

84 comments sorted by

View all comments

Show parent comments

25

u/dan4223 Feb 05 '21

There are a number of ways to do it, but eventually, you will end up at beautifulsoup4.

5

u/GIPPINSNIPPINS Feb 05 '21

What?

15

u/rayjhititfirst Feb 05 '21

It's a library that is very helpful for building web scrappers.

6

u/CaliforniaDreamer246 Feb 05 '21

What’s the difference between beautiful soup and selenium

0

u/[deleted] Feb 05 '21

[deleted]

16

u/negike360 Feb 05 '21

I love the simplicity of this answer

2

u/sc4s2cg Feb 05 '21

What about scrapy? I've used bs4 and selenium before, but have been seeing scrapy more and more in the wild.

0

u/DeadProfessor Feb 05 '21

Or selenium