Basics/principles Flashcards
Variable
A container for a value, it behaves as the value it contains.
Float
A number with a decimal portion
Integer (Int)
A whole number
Type
Can be used to identify the value type of a variable
String or “str”
A series of letters
Boolean
A value that is either “true” or “false”
Multiple assignment
Allows you to give values to multiple variables in one line of code
What is this line of code an example of?
Name, age, cool = “alex”, 15, True
This is an example of multiple assignment
What is this an example of?
Alex = Dino = James = Rhea = “cool”
This is an example of multiple assignment.
Type casting
Converting the data type of a value to another data type e.g from integer to string
Input()
This allows for the user to give input
What is this doing?
Name = input(“What is your name?”)
This is assigning the users input to the variable “Name”
An absolute value
How far away a number is from 0
Slicing
Creating a substring by extracting elements from another string
Indexing[]
A form of slicing that uses square brackets