REMEMBER PYTHON

MINTE9
2REMEMBER




Variables

p33 In programming an assignment creates a variable and gives it value.
 
>>> message = 'Hello World!'
>>> print(message)

Hello World!
... 3 lines
˄˄˄
If you give an illegal name of a variable, you get a syntax error.
 
>>> name@ = "John"
SyntaxError: invalid syntax

>>> class = "class 1"
SyntaxError: invalid syntax, class is a reserved keyword
... 4 lines
˄˄˄
p36 ! An expression is a combination of values, variables, and operators. When you type an expression at the prompt, the interpreter evaluates it.
 
>>> n=17   # n has the value 17
>>> n+25   # n + 25 has the value 42
42
... 3 lines
˄˄˄
Statement    (2/2)

Statement

p36 ! A statement is a unit of code that has an effect. When you type a statement, the interpreter executes it.
 
>>> n = 17    # statement 1
>>> print(n)  # statement 2
17
... 3 lines
˄˄˄
p39 The + operator concatenates two strings. The * operator performs repetitions on strings.
 
>>> s1 = 'Hello'
>>> s2 = 'World'
>>> s1 + ' ' + s2
'Hello World'

>>> 'Spam'*3
'SpamSpamSpam'
... 6 lines
˄˄˄

Questions    
No. 3   Functions
CARD
02

        A B C D E F
🔔
1/1