Writing Python code, Coffee Shop Script.

Writing Python code, Coffee Shop Script.
Photo by Nolan Issac / Unsplash

My journey started with Python back when i had a Raspberry Pi2 b+ and a PiGlow module that had a series of lights that you could control with writing some basic Python code. To get back into the flow of writing code i decided to go back and learn some fundamental basics of Python by writing a simple Coffee Shop script.

This script will show usage of the following

  • IF and ELSE - Used on questions (Yes & No)
  • Functions - In this case the exit() is used to exit the program when a particular name is mentioned on first question.
  • Integer addition - There are two examples of integer addition used, the first one is for price and the second is used when adding additional drinks to the order ( original price plus extra price )
  • Variables - Plenty used on pretty much every line.
  • Operators, "and" "or" used for asking if the customer is evil "and" done good deeds, the "OR" is used in the extra names for banned list. Both used together will decide if the band user can enter the shop.
  • Import module - Imported pYfiglet for ASCII logo.

To see the full script you can visit my github https://github.com/Stratuscodelab/drew-coffee-shop/blob/main/shop.py

To run the script make sure you have python installed and perform the following

git clone https://github.com/Stratuscodelab/drew-coffee-shop/blob/main/shop.py

Then just run the script

python3 shop.py

Camping lists + Methods

This next script focuses on Lists and Methods, i have used a friendly Camping theme to make understanding easier.

  • Lists - The basic itinery of items needed to go on the adventure.
  • Methods - The different techniques used to add and remove items from the list,
  • String, Floater, Integer and Boolean - Using these within a list.

To see the full script you can visit my github here

git clone https://github.com/Stratuscodelab/Camping

You can then run the script

python camp.py

I would recomend uncommenting some of the methods and trying out Append, extend, insert, remove, clear and pop.

This script will be updated with further fun stuff, subscribe to this blog if you are interested to see more articles on python.

exit()