Computer Club - Session 2
Computer Club - Session 2
Computer Club - Session 2
Python 02
Where nerdiness meets fun to unlock endless possibilities
TABLE OF CONTENTS
01 02 03
Recap Assessing Logic Branching
04 05 06
Looping with Looping with Summary
while for
How This Will Work
Give Examples
Explain
Quiz
Solve Exercise
01
Recap
What is an IDE?
An IDE, or an Integrated
Development Environment,
is a tool that allows you to
write and run code.
Input Casting
You can get a user’s input Changing variable from one
using the input() function type to another
Arithmetic Operations
Addition
a+b
Subtraction
a-b
Operations
Multiplication
a*b
Division
● Real Division: i/j
● Integer Division: i//j
Arithmetic Operations
Modulus
a%b
Other Returns the remainder of a/b
Operations
Power
a**n
and
Returns True if both operands are
True
Operators or
Returns True if either of the
operands is True
not
Returns the inverse of the value of
the operand
Quiz 1
What is the result of the following operations?
1) 34 != 43 Answer: True
82>18: True
82<64: False
82>18 and 82<64: False
Helpful Tip: You can add \t or \n to your
strings to insert a tab or a new line
03
Branching
If Statements
The python if keyword is used to evaluate
a given condition (Boolean value) as True
or False, and runs the code only if the
condition(s) are met.
if condition:
statements to execute
OTHER CONCEPTS
else elif
If the conditions of the If the condition of the
previous if/elif statement(s) previous if statement is not
are not met, then the code in met, then the code checks for
the else block is executed. another condition to execute
the elif block.
Syntax:
Syntax:
if condition:
statements to execute if condition_1:
else: statements to execute
statements to execute elif condition_2:
statements to execute
Exercise
Syntax:
○ for variable in range(range):
statements to execute
continue
Skips current iteration and
proceeds to the next iteration
Keywords
break
Breaks out of the loop and
terminates it, moving on to the
next statement
Exercise
● Logic Operators
● If Statements
● While Loops
● For Loops