1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
x = 5
Variable Assignment
x=5
x+2
7
Calculations With Variables
Sum of two variables
x=5
x-2
3
Calculations With Variables
Subtraction of two variables
x=5
x*2
10
Calculations With Variables
Multiplication of two variables
x=5
x**2
25
Calculations With Variables
Exponentiation of two variables
x=5
x%2
1
Calculations With Variables
Remainder of two variables
x=5
x/float(x)
2.5
Calculations With Variables
Division of two variables
str()
Types and Type Conversion
'5', '3.45', 'True' (Variables to strings)
int()
Types and Type Conversion
5, 3, 1 (Variables to integers)
float()
Types and Type Conversion
5.0, 1.0 (Variables to floats)
bool()
Types and Type Conversion
True, True, False (Variables to booleans)
help(str)
Syntax to Asking For Help
Strings
my_string = 'thisStringIsAwesome'
my_string 'thisStringIsAwesome'
String Operations
>>> my_string * 2
'thisStringIsAwesomethisStringIsAwesome'
>>> my_string + 'Innit'
'thisStringIsAwesomeInnit'
>>> 'm' in my_string
True
String Indexing
>>> my_string[3]
>>> my_string[4:9]
my_string.upper()
String Methods
String to uppercase
my_string.lower()
String Methods
String to lowercase
my_string.count('w')
String Methods
Count String elements
my_string.replace('e', 'i')
String Methods
Replace String elements
my_string.strip()
String Methods
Strip whitespaces