Python
/
Language
- 1 Language 9
-
Hello World
-
Variables
-
Functions
-
Conditional
-
Operators
-
While
-
Turtle
-
Script Mode
-
Debugging
- 2 Strings 6
-
Slice
-
Raw Strings
-
Regex
-
Validation
-
Config
-
Escape
- 3 Collections 5
-
Lists
-
Dictionaries
-
Efficiency
-
Tuples
-
References
- 4 Functions 5
-
Recursion
-
Factorial
-
Modulus
-
Reassignment
-
Approximate
- 5 Storage 8
-
Files
-
Databases
-
Pipes
-
With open
-
Shelve
-
Zip
-
Csv
-
Json
- 6 Class 4
-
Definition
-
Attributes
-
Functional
-
Methods
- 7 Goodies 5
-
Conditional Expression
-
List Comprehension
-
Generator
-
Named Tuple
-
Modules
- 8 Applications 5
-
Pythagora
-
Palindrome
-
Binary Search
-
Conway Game
-
Coin Flip
- 9 Scheduler 4
-
Time
-
Multithreading
-
Subprocess
-
Logging
- 10 Packages 2
-
Clipboard
-
Ocr
/
Variables
➟
➟
Last update: 13-05-2022
Variables
p33 In programming an assignment creates a variable and gives it value.
# An assignment creates a variable and gives it value.
# If you give an illegal name of a variable, you get a syntax error.
# An expression is a combination of values, variables, and operators.
# You can assign multiple variables in on line
# Assignment
#
message = 'Hello World!'
print(message) # Hello World!
# Illegal name variables
#
# name@ = "John"
# class = "myClass" # SyntaxError: invalid syntax
# Expression
#
n = 17
n = n + 24
print(n) # 41
# Multiple assignement
#
a, b, c = [1, 2, 3]
assert a == 1
assert b == 2
assert c == 3
Statements
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
Operators
p39 The + operator concatenates two strings.
# The + operator concatenates two strings.
# The * operator performs repetitions on strings.
s1 = 'Hello'
s2 = 'World'
print(s1 + ' ' + s2) # 'Hello World'
print('Spam'*3) # 'SpamSpamSpam'
➥ Questions github Language