Python - The Basics
Python - The Basics
greeting = “Hello”
name = input (“Please enter your name: ”)
print (greeting + ‘ ‘ + name)
Output
Please enter your name: Tommy
Hello Tommy
Print strings over several lines
The forward slash n causes the cursor to start a new line.
Splitstring = “This string has been\nsplit over\nseveral\nlines”
print(Splitstring)
Output:
This string has been
split over
several
lines
The forward slash t causes the cursor to place a tab at the next
tab position.
tabbedString = “1\t2\t3\t4\t5\t”
print(tabbedString)
Output:
1 2 3 4 5
Exercise 1
1. Write a program in python to output the
following:
Number 1 The Larch
Number 2 The horse chestnut
Number 3 The evolution process