Topic 1 - Session 1 - MTA Intro Course Flashcards
Describe three core aspects of defining a variable
- Variables cannot have spaces in their names
- Variables are case-sensitive
- Variables cannot begin with a number
Which type of variable use decimals?
Floating
Describe what a variable is in simple terms
A variable is a container that can be used to store information which can be used later.
When declaring variables in python, what is best practice?
It is best practice to use camel casing.
What punctuation symbol should we use to combine strings and numbers in a print statement?
A comma
Explanation:
A comma removes the need to convert the integer to a string.
How many values does a Boolean variable have?
Two values - either True or False
What is ‘\n’ called and what does it do?
It is called an escape character and it is used to send text to a new line.
Are Boolean values case sensitive?
Yes, the values can only be either True or False
What is type casting in Python?
This is when you convert a integer or a float value into a string
str(variable_name)
When converting a float to an integer, what must you keep in mind?
The casting will result in the float number being rounded down.
Lists are known as what in other programming languages?
Arrays
Lists use what type of brackets?
Square brackets
list = [ ‘dog’ ]
How would you add a new value to the end of this list?
list = [ ‘dog’ ]
list.append(‘cat’)
How would you remove a value from a list?
list.remove(‘dog’)
How would you sort a list in alphabetical order?
list.sort()