Data Types Flashcards
What is the limit to how long an integer can be in Python 3?
In Python 3, there is effectively no limit to how long an integer value can be. Of course, it is constrained by the amount of memory your system has, as are all things, but beyond that an integer can be as long as you need it to be.
How can you indicate a base of Octal for an integer?
0o (zero + lowercase letter ‘o’)
0O (zero + uppercase letter ‘O’)
How can you indicate a base of Binary for an integer?
0b (zero + lowercase letter ‘b’)
0B (zero + uppercase letter ‘B’)
How can you indicate a base of Hexadecimal for an integer?
0x (zero + lowercase letter ‘x’)
0X (zero + uppercase letter ‘X’)
What can you follow a float with to signify scientific notation?
The character e or E followed by a positive or negative integer may be appended to specify scientific notation
How are complex numbers specified?
+j
What is the string type in python called?
str
What are two different ways to delimit string literals?
String literals may be delimited using either single or double quotes.
What is the best way to escape either single or double quote? Without using “".
If you want to include either type of quote character within the string, the simplest way is to delimit the string with the other type.
For example:
print(“This string contains a single quote (‘) character.”)
print(‘This string contains a double quote (“) character.’)
What is the escape character in python?
Backslash: “"
A backslash character in a string indicates that one or more characters that follow it should be treated specially. (This is referred to as an escape sequence, because the backslash causes the subsequent character sequence to “escape” its usual meaning.)
How can you escape a newline?
\newline - terminates input
How can you add tab to a string?
\t
How can you carriage return using escape characters?
\r
What is a raw string?
Raw string literal is preceded by r or R, which specifies that escape sequences in the associated string are not translated. The backslash character is left in the string
> > > print(r’foo\nbar’)
foo\nbar
How can you denote a raw string?
r or R