Start small, ask questions, practise in your editor, and build projects one step at a time.
Your first goal is simple: install Python and make it print a message. You do not need to understand everything yet.
Open the Python website in a new browser tab and follow the setup steps.
Type these lines into the IDLE Shell. Press Enter after each line.
print("Hello Python")
Var1 = 10
Str1 = "Py"
print(Var1, Str1)
Hello Python and then 10 Py? Both printed? IDLE works.NotebookLM is your AI Tutor to learn the concepts behind code. Use it to ask questions and understand examples, not just copy answers.
If you have Gmail: Right-click the link and choose Open link in new tab: gmail.com β Login.
If you don't have Gmail: Right-click and open accounts.google.com/signup in a new tab β Create an account β Then log in.
Keep this setup tab open, with Gmail in a new tab.
Follow the steps in order to add all three learning sources.
You will use VS Code to write and organise Python programs. GitHub Copilot can help explain code and suggest ideas as you learn.
This account is used to sign in to GitHub Copilot.
Open code.visualstudio.com in a new tab β Download β Install.
Inside VS Code, follow these steps:
In VS Code, choose File β Open Folder and open or create the folder named PythonPractice. Follow the topics in this order. Type, run, observe, and experiment with each example.
Var1 = 1
Str1 = "Py"
print(Var1, Str1)
x = 10
name = "Python"
print(type(x), type(name))
print("Learn", "Python", sep=',')
name = input("Your name?\n")
print("Welcome", name)
# comment
if True:
print("inside - 4 spaces")
print("outside")
yearofexp = 4
if yearofexp > 3:
bonus = 10000
else:
bonus = 5000
print(bonus)
for i in range(3):
print("Hi", i)
if and else blocks choose a bonus based on the condition. The for loop runs three times, with i taking the values 0, 1 and 2.nums = [1,2,3]
t = (1,2,3)
s = {1,2,2,3}
p = {1: 6, 2: 6, 3: 6, 4: 6, 5: 6, 6: 6}
for i, j in p.items():
print("ROW:", i, "-\t", j * '1 ')
nums is a list.t is a tuple.s is a set, so repeated values are stored only once.p is a dictionary mapping each key to the value 6.The loop visits each key-value pair in p and prints a row made from repeated 1 text.
These project examples were included in the original learning document as an optional commented-out section. Try them after you are comfortable with functions, loops, conditions and recursion.
def letusplay():
p = {1: 6, 2: 6, 3: 6, 4: 6, 5: 6, 6: 6}
for i, j in p.items():
print("ROW:", i, "-\t", j * '1 ')
user_response = input('Do you want to play?\n')
if user_response.lower() in ["yes","y"]:
letusplay()
def hanoi(n, source, target, aux):
if n == 1:
print(f"Move disk 1 from {source} to {target}")
return
hanoi(n-1, source, aux, target)
print(f"Move disk {n} from {source} to {target}")
hanoi(n-1, aux, target, source)
hanoi(3, 'A', 'C', 'B')