.format() Flashcards

1
Q

> > > pi = 3.141596
‘pi = {___}’.format(pi)
3.141596

A

> > > pi = 3.141596
‘pi = {}’.format(pi)
3.141596

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

> > > pi = 3.141596
‘pi = {___}’.format(pi)
3.14

A

> > > pi = 3.141596
‘pi = {:2f}’.format(pi)
3.14

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

> > > pi = 3.141596
‘pi = {___}’.format(pi)
***3.141596

A

> > > pi = 3.141596
‘pi = {:>11}’.format(pi)
**
3.141596

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

> > > pi = 3.141596
‘pi = {___}’.format(pi)
3.141596***

A

> > > pi = 3.141596

|&raquo_space;> ‘pi = {:*

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

> > > pi = 3.141596
‘pi = {___}’.format(pi)
3.141596

A

> > > pi = 3.141596
‘pi = {:*^12}’.format(pi)
3.141596

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

> > > pi = 3.141596
‘pi = {:*^11}’.format(pi)
*3.141596**

A

> > > pi = 3.141596
‘pi = {:*^11}’.format(pi)
*3.141596**

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

> > > pi = 3.141596
‘pi = {___}’.format(pi)
3.141596 (9 spaces)

A

> > > pi = 3.141596
‘pi = {:17}’.format(pi)
3.141596

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

What does ‘{s}’.format(x) do?

A

Inserts string ‘x’ at {s}

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

What does ‘{c}’.format(x) do?

A

Inserts unicode character ‘x’ at {c}, where ‘c’ is an integer

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

What does ‘{b}’.format(x) do?

A

Inserts binary number ‘x’ at {b}, where ‘b’ is an integer

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

What does ‘{d}’.format(x) do?

A

Inserts decimal integer ‘x’ at {d}

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