2.2 - coding techniques Flashcards
how do you ask a user to input something
variable = input(“text “)
what is it called to change the type of a variable
casting
what are the 4 main types of variable
str - (string) any characters
int - (integer) whole number
float - (floating point) decimals
bool - (boolean) T/F
how do you change the type of a variable
variable2 = int(variable1)
what is modulus (MOD)
the remainder of dividing two numbers (%)
what is the quotient (DIV)
the exact number of times something divides into something else (//)
how do you code an exponent
**
how do you multiply, divide, add or subtract variables
*, /, +, -
what is a string
a set of characters that can include letters, numbers, spaces and special characters
what is concatenation
adding two strings together (“variable1” + “variable2”)
what is string traversal
locating or making changes to only a certain character or characters rather than the whole string
how do you change case
variable.upper or variable.lower
how do you find the length of a string
len(variable)
how do you create a substring
variable2 = variable1[start:end]
what are the six comparisons you can do with a number
==, !=, <, >, <=, >=