Some Adaptable Exercises For Programming Practice


Here are five nice ideas for programming exercises, originally intended for Python beginners but probably applicable to many languages.


From Reddit r/learnpython posted by u/NoSide005

"5 Projects For Beginners To Learn Python"



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.

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.

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).

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.

Bots & web scraping
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.



Comments

Popular posts from this blog

Humble Beginnings MDN