In this lesson we will learn about...
The "Hello, World!" program is the most basic you can run, and is traditionally your first program.
print("Hello, World!")
Hello, World!
# Correct
if True:
print("True")
else:
print("False")
True
# Incorrect
if True:
print("True")
else:
print("False")
File "<ipython-input-3-71288eeef709>", line 3 print("True") ^ IndentationError: expected an indented block
'
), double ("
), or triple ('''
or """
) quotes to denote string literals\
) to escape a quotation mark in a string"
inside '
, and vice versastring1 = 'string'
string2 = "string"
sentence = "This is a sentence \"with double quotes\" "
sentence2 = 'This is also a sentence "with double quotes in it"'
multiline = """This is a quote
that takes multiple lines. Notice
how the newlines are part of the string too!"""
print(string1)
print(string2)
print(sentence)
print(sentence2)
print(multiline)
string string This is a sentence "with double quotes" This is also a sentence "with double quotes in it" This is a quote that takes multiple lines. Notice how the newlines are part of the string too!
Comments are pieces of text in a python file that are not interpreted as code.
# This is a comment
a = 2 # This is also a comment
# blank lines also are ignored!
input()
to get input from the keyboard.print()
to send output to the screen.text = input("Enter some text: ")
print(text)
Enter some text: This is from the keyboard. This is from the keyboard.