Data Types Flashcards

1
Q

What is the limit to how long an integer can be in Python 3?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you indicate a base of Octal for an integer?

A

0o (zero + lowercase letter ‘o’)

0O (zero + uppercase letter ‘O’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you indicate a base of Binary for an integer?

A

0b (zero + lowercase letter ‘b’)

0B (zero + uppercase letter ‘B’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you indicate a base of Hexadecimal for an integer?

A

0x (zero + lowercase letter ‘x’)

0X (zero + uppercase letter ‘X’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can you follow a float with to signify scientific notation?

A

The character e or E followed by a positive or negative integer may be appended to specify scientific notation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are complex numbers specified?

A

+j

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the string type in python called?

A

str

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are two different ways to delimit string literals?

A

String literals may be delimited using either single or double quotes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the best way to escape either single or double quote? Without using “".

A

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.’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the escape character in python?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you escape a newline?

A

\newline - terminates input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you add tab to a string?

A

\t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you carriage return using escape characters?

A

\r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a raw string?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you denote a raw string?

A

r or R

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the benefits of a triple quoted string?

A

Triple-quoted strings are delimited by matching groups of three single quotes or three double quotes. Escape sequences still work in triple-quoted strings, but single quotes, double quotes, and newlines can be included without escaping them. This provides a convenient way to create a string with both single and double quotes in it

17
Q

What are potential values for a boolean data type?

A

Objects of Boolean type may have one of two values, True or False: