Python 100 projects in 100 days — Learning Journal
Day one — Brand Name Generator
Let me start this journey by expressing my appreciation for folks who would like follow along to hone your Python skills. I will be documenting every project step-by-step along with tips.
With that said, let us begin our day one!
Here are a couple of ways you may put python in use.
1 Repl.it — Free registration and a bunch of features provided
2 Install Python locally (using Mac)
Installing Homebrew
Open terminal and type in
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
.
.
.
==> Installation successful!==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations==> Next steps:
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
Verify Homebrew installation
$ brew --version
Homebrew 2.4.16
Homebrew/homebrew-core (git revision 23bea; last commit 2020-09-04)
Homebrew/homebrew-cask (git revision 5beb1; last commit 2020-09-05)
Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH
environment variable. You can do this by adding the following line at the bottom of your ~/.profile
file
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
2. Python (the version must be 3.7 to make sure that all functions will be available to present intended outcome) is required to be installed
Installing Python3
Now, we can install Python 3:
$ brew install python
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
==> Updated Casks
sessionWarning: python@3.8 3.8.5 is already installed and up-to-date
### my python was preinstalled, you may see different installation process. And it may take a while before python is fully installed
Verify is your python3 is installed
$ python3 --version
Python 3.8.5
Notes: you may set your default python as latest version by applying following code
$ unlink /usr/local/bin/python
$ ln -s /usr/local/bin/python3.8 /usr/local/bin/python
If using windows, please follow instruction below to install Chocolatey, then install Python using it
1 Install Chocolatey
2 Install Python
Now let’s work on our project
#1. Create a greeting for your program.print("Welcome to the Brand Name Generator.")#2. Ask the user for the city that they grew up in.city = input("What's name of the city you grew up in?\n")#3. Ask the user for the name of a pet.pet_name = input("What's your pet's name\n")#4. Combine the name of their city and pet and show them their band name.print("Your band name could be " + city + " " + pet_name)#5. Make sure the input cursor shows on a new line, see the example at:# https://band-name-generator-end.appbrewery.repl.run/
Output:
Welcome to the Brand Name Generator.
What's name of the city you grew up in?
Beijing
What's your pet's name
Cody
Your band name could be Beijing Cody
Now give it a shot on your own!
Notes:
1 double quote inside double quote may cause problem, so you may apply single quote inside double quote or vice versa.
“ ‘’ ”
or ‘ “ ” ’
2 number can’t be used in front of a variable and _ should be used in between words
1variable is not allowed
variable1 is allowed rather
3 To start a new line by using \n
4 To combine variables with printouts
print("Your band name could be " + city + " " + pet_name)
5 To create variable as below
city = input("What's name of the city you grew up in?\n")
Give yourself a thumb up, we will go continue tomorrow!