What will we cover?
We will take you from knowing nothing about Python, what to install to get started, how to write your first programs, make a few interactive programs, and learn a few string methods.
- Start from Scratch: Take you from having no prior knowledge of Python to getting started with the language.
- Installation and Setup: Guide you through the installation process and help you set up the necessary tools to write Python programs.
- Write Your First Programs: Learn the basics of Python syntax and write your initial programs to get hands-on experience.
- Build Interactive Programs: Dive deeper into Python and create interactive programs to enhance user interaction.
- Explore String Methods: Discover essential string methods in Python to manipulate and work with text effectively.
If you find yourself intrigued and eager for more, we offer a free 8-hour Python course for beginners. This course consists of 17 lessons, including video tutorials and hands-on projects, providing a comprehensive learning experience.
Step 1: Install JuPyter Notebook and Launch your first Notebook
Anaconda installs all you need and it is free. That is, it installs Python, most of the libraries you need, and a simple interactive environment to develop Python code in, the JuPyter Notebook.
Shortly explained.
- Anaconda installs all and you can launch JuPyter Notebook from Anaconda Navigator (often just called Anaconda).
- JuPyter Notebook can navigate through your files and open Notebooks, where you write your code.
How to get started?
- Go to Anaconda and download the individual edition (it is free).
- It will install Python and Jupyter notebook. That is all you need to get started and it is all free.
- Launch Anaconda Navigator.
- Anaconda launched Jupyter Notebook.
- Navigate to a place where you want to save your files.
- Create a new Python Notebook with the “new” menu on the right.
Step 2: Write your first program “Hello, World!”
Click on the first cell and write the following code.
print('Hello, World!')
Press SHIFT-ENTER to execute it.
It should print “Hello, World!” below the cell.
The Hello, World! program is traditionally the first program you write in a language, which demonstrates the syntax.
Python has very little syntax and is easy to use. To compare with other languages see Wikipedia.
Step 3: Input a string from the user
Making programs interactive is fun. The first step is to get the user to type something and let your program do something with that.
s = input("What is your name? ")
print(s)
Look at the code and guess what it does.
Then copy the code into a cell and execute it.
What happened?
It prompted you for something – and you might type some letters, say, your name. Then what will it do? Yes, print your name.
Step 4: Your first interactive program
Actually, you have the tools now to make simple interactive programs.
Let’s try that now.
name = input("What is your name? ")
print("Hello", name.capitalize())
age = input("How old are you? ")
print("You are", age, "years old")
See how simple that is.
Well, you learned a few things here.
if you have a string (like, name), then you can apply capitalize() on it. What does it do?
Well, if you type your name in lowercase, then it will capitalize your name for you. If it already is capitalized, it will do nothing.
Now that is smart.
Step 5: A few methods on strings
Like, capitalize() there are a lot of other methods you can apply.
In the beginning, you probably worry about remembering them all. I got good news for you – you do not need to. You will most likely only use a few and the others you will look up when you need them.
But a few ones that can be funny to master are the following.
"Rune".upper()
"Rune".lower()
"223".isdecimal()
"Rune".isdecimal()
Try to copy each one into a cell by itself and see what it does. It will most likely make sense to you.
Notice, if you copy them all into one cell in JuPyter Notebook, then it will only give the output of the last statement of the cell. Therefore, try one line at a time in one cell.
Notice, that the “Rune” is a string and the methods could be applied to variables as well.
s = "Rune"
s.upper()
Step 6: Replace something in a string
My favorite and most used string method is replace(.)
Let’s just try it.
name = "Rune"
name.replace('R', 'S')
Put it into a cell and execute.
It will output Sune. It will change all occurrences of R to S.
Notice, that these methods are case sensitive, meaning, that the following code.
name = "Rune"
name.replace('r', 's')
It will output Rune because there is no lowercase r to replace.
Step 7: What next?
I am happy you asked.
If this is something you like and you want to get started with Python, then this is the first lesson of an 8 hours FREE video course with full explanations, projects on each level, and guided solutions.
Check out the first lesson here.
What about the full course? You get the next lesson here where you will learn about variables in Python, which is part of 17 lessons.
The course is structured with the following resources to improve your learning experience.
- 17 video lessons teaching you everything you need to know to get started with Python.
- 34 Jupyter Notebooks with lesson code and projects.
- A FREE eBook to support your Python learning.
See the full FREE course page here.
Python for Finance: Unlock Financial Freedom and Build Your Dream Life
Discover the key to financial freedom and secure your dream life with Python for Finance!
Say goodbye to financial anxiety and embrace a future filled with confidence and success. If you’re tired of struggling to pay bills and longing for a life of leisure, it’s time to take action.
Imagine breaking free from that dead-end job and opening doors to endless opportunities. With Python for Finance, you can acquire the invaluable skill of financial analysis that will revolutionize your life.
Make informed investment decisions, unlock the secrets of business financial performance, and maximize your money like never before. Gain the knowledge sought after by companies worldwide and become an indispensable asset in today’s competitive market.
Don’t let your dreams slip away. Master Python for Finance and pave your way to a profitable and fulfilling career. Start building the future you deserve today!
Python for Finance a 21 hours course that teaches investing with Python.
Learn pandas, NumPy, Matplotlib for Financial Analysis & learn how to Automate Value Investing.
“Excellent course for anyone trying to learn coding and investing.” – Lorenzo B.
