3. Variable, Expressions, Statements Flashcards
i index is used when we want to make
a loop
without i, the loop will continue
infintely
elements needed in loop
Initialization Statement (i = x)
Loop Condition (if i == 10)
Update Statement (i = i+1)
Use of type()
to get the type a value/variable belongs
naming rules:
1st Character
- Alphabets (lowercase or uppercase)
* Underscore ( _ )
naming rules:
2nd Character onwards
- Alphabets (lowercase or uppercase)
- Underscore ( _ )
- Digits
naming rules:
CANNOT be
Python’s keywords,
/
(floating-point division)
//
(integer division)
**
Exponentiation
mod is the
remainder of a division
str +
Concatenation
“Tony” + “Stark” = “TonyStark”
str *
Repetition
“Tony” * 3 = “TonyTonyTony”
Rules of Precedence =
PEMDAS
Expressions
A combination of values, variables, and operators.
input:
name = input(“Enter your name”)
“Enter your name” is the
prompt
input:
name = input(“Enter your name”)
Output?
Enter your name
print(‘python’,’is’,’easy’)
By default,
the data will be separated by space when shown.
Use the sep argument to
change the separator to any string.
Use the end argument
to change the end character for the
print statement.
mod can be use to
check whether one number is divisible by another
extract the right-most digit or digits from a number