Skip to content

Bombus17/Python_mini_projects

Repository files navigation

Python Projects

Although I can code in other languages, I am new to Python. This repo contains projects developed as I extend my Python coding skills. Most are sourced from those listed in https://github.com/jorgegonzalez/beginner-projects. I will be adding more items as I progress. Have also included additional projects. Broadly speaking, each project increases in level of difficulty (see the main listing for further details).

Contributing Feel free to contribute to this repository or other solutions. All feedback welcome.

99 Bottles

A program that uses a built in function to print out every line to the song "99 bottles of beer on the wall."

What I learned:

  1. Defining functions in Python
  2. If statements and coonditional tests
  3. Print statements
  4. Working with strings

Armstrong Number

An Armstrong Number is any number of n digits which is equal to the sum of nth power of digits in the number. For example: 92727 = 9^5 + 2^5 + 7^5 + 2^5 + 7^5 (where n = 5). A program to check whether a given number is an Armstrong Number. Users may enter multiple tests.

What I learned:

  1. input() function
  2. User prompts
  3. While loops
  4. Error Handling

Magic 8 Ball

Simulation of a magic 8-ball. Allow the user to enter their question and display an in progress message. Create 20 responses, and show a random response. Allow the user to ask another question or quit. Program includes a GUI where users can enter the following questions:

  • ask
  • clear (the text box)
  • play again
  • quit (this must close the window)

What I learned:

  1. Importing modules
  2. Working with classes
  3. Creating a GUI with Tkinter
  4. Lists and arrays

Pythagorean Triples Checker

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a² + b² = c² and (a and b are cathetus and c is the hypotenuse). Allows the user to input the sides of any triangle in any order and returns whether the triangle is a Pythagorean Triple or not. Users may reuse the program without having to quit.

What I learned:

  1. Sorting
  2. Variables
  3. Nested for loops vs list comprehensions

Fibonacci Sequence

Fibonacci numbers (Fn) form the Fibonacci Sequence where each number is the sum of the two preceeding ones. So for 0 and 1, F0 = F1 and for n > 1, Fn = Fn-1 + Fn-2; (see also the Golden ratio). This program uses a function that allows the user to find the value of the nth term in the sequence by inputting the desired term. There are two solutions; the first using a loop (less performant at as n increases).The second solution uses recursion.

What I learned:

  1. If..else statements
  2. Parallel assignment
  3. Recursive functions
  4. Performance benchmarks for functions

Multiplication Tables

Output a multiplication table in grid format for a given integer.

What I learned:

  1. Nested for loops
  2. Counters