General python Flashcards
(212 cards)
How do you get a new blank row into code?
\n , print()
What is the escape character?
\
What does \ do?
Announces that the string should be paused and that the character after means something
How do you print the character \
print(“\”)
What happens when you pass muliple arguments to a print function
1) It combines them all on one line
2) It puts a small between the outputted arguments
What is a positional argment?
The location determines what it does
How do you use keyword arguments?
1) keyword = value
2) after positional arguments
What does the default end keywork argument do in print
\n
How do you alter the default behaviour of print to insert a space between arguments?
sep =
What is a literal?
Data you can determine the value of without any additional knowledge e.g. 123 vs c
What are the 2 ways to show quotation marks in Python
" or use ‘’ instead of “”
How do you encode ‘to the power of’
**
What does print(6/2) give you?
A float
What does // do?
Integer division
What happens when the result of // is not an integer?
Rounds to the lower number (ie. floor division)
What is the result of print( 6 // - 4)?
-2
What type does the % operation result in?
Float
what is a unary and a binary operatory
Binary expect 2 arguments, unary expects 1
Is python predominantly right side or left side binding?
Left side
What is the exception to left side binding
Exponentiation
What is the order of priority of operators?
1) + - (unary)
2) **
3) * / %
4) + - (binary)
5) , >=
6) ==, !=
What does a variable contain?
A name and value
How do you evaluate the square root of something?
** 0.5
What does input() store values as?
A string