*www.codingdojo.com (on indeed.com listings)
**            >>>   Exponent                    >>>  2 ** 3 = 8
% >>> Modulus/Remainder >>> 22 % 8 = 6
// >>> Integer division >>> 22 // 8 = 2
/ >>> Division >>> 22 / 8 = 2.75
* >>> Multiplication >>> 3 * 3 = 9
- >>> Subtraction >>> 5 - 2 = 3
+ >>> ADITTION >>> 22 + 8 = 30

## Examples of expressions in the interactive shell:

>>> 2 + 3 * 6
20
>>> (2 + 3) * 6
30
>>> 23 % 7
2
>>> (5 - 1) * ((7 + 1) / (3 - 1))
16.0
>>> 3-3
0
>>> 3/3
1
>>> 3*3
9
>>> 3**3
27

String Concatenation and Replication

>> 'Alice' 'Bob' 
'AliceBob'
>>> 'Alice' * 5
'AliceAliceAliceAliceAlice'

Variables

>>> spam = ‘Hello’
>>> spam
‘Hello’

The print() Function

>>> print('Hello world!')
Hello world!

The input() Function

>>> print('What is your name?')   # ask for their name
>>> myName = input()
>>> print('It is good to meet you, {}'.format(myName))
What is your name?
Al
It is good to meet you, Al

The len() Function

>>> len('hello')
5
>>> a = [1, 2, 3] 
>>> if a:
>>> print("the list is not empty!")

The str(), int(), and float() Functions

>>> str(29)
'29'
>>> print('I am {} years old.'.format(str(29)))
I am 29 years old.
>>> str(-3.14)
'-3.14'
>>> int(7.7)
7
>>> int(7.7) + 1
8

Flow Control

>>> 42 == 42
True
>>> 40 == 42
False
>>> 'hello' == 'hello'
True
>>> 'hello' == 'Hello'
False
>>> 'dog' != 'cat' #not equal to
True
>>> 42 == 42.0
True
>>> 42 == '42'
False

Boolean evaluation

>>> True is True
True
>>> True is not False
True
###These statements are equivalent:>>> if a is True:
>>> pass
>>> if a is not False:
>>> pass
>>> if a:
>>> pass

Mixing Boolean and Comparison Operators

>>> (4 < 5) and (5 < 6)
True
>>> (4 < 5) and (9 < 6)
False
>>> (1 == 2) or (2 == 2)
True
##You can also use multiple Boolean operators in an expression, along with the comparison operators:>>> 2 + 2 == 4 and not 2 + 2 == 5 and 2 * 2 == 2 + 2
True

if Statements

if name == 'Alice':     
print('Hi, Alice.')

else Statements

name = 'Bob'
if name == 'Alice':
print('Hi, Alice.')
else:
print('Hello, stranger.')

elif Statements

name = 'Bob'
age = 5
if name == 'Alice':
print('Hi, Alice.')
elif age < 12:
print('You are not Alice, kiddo.')
name = 'Bob'
age = 30
if name == 'Alice':
print('Hi, Alice.')
elif age < 12:
print('You are not Alice, kiddo.')
else:
print('You are neither Alice nor a little kid.')

while Loop Statements

spam = 0
while spam < 5:
print('Hello, world.')
spam = spam + 1

break Statements

while True:
print('Please type your name.')
name = input()
if name == 'your name':
break
print('Thank you!')

--

--

--

I enjoy exploring new things !

Love podcasts or audiobooks? Learn on the go with our new app.

Pickle Press — w/c May 24th 2021

Mobile Penetration Tester Roadmap

The Worst Enemy of Progress (2/5)

Accident Lawyer Sandy Utah

accident lawyer sandy utah

How To Customize Your macOS Terminal

Focus on accessibility

Git AND GitHub

Cookie Insured Farms V1 → V2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rafi Ridzwan

Rafi Ridzwan

I enjoy exploring new things !

More from Medium

My encounter with a brown recluse spider in Mexico

The Big WHY of Organisational Resilience

The Cheap Train to Machu Picchu

colonial-era cathedral with blue sky and clouds

Government Policy, Genetic Selection, and a Girl Named Bella