General Flashcards

1
Q

Printing documentation strings

A

> > > print(math.tanh.__doc__)

Returns the document string that is triple quotes “”” “””

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

Converting integers and strings to floats

A

> > > float(3)

3.0

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

Str(n) function

A

Converts any number to a string

> > > str(85)
‘85’

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

Int(x) function

A

Chops off extra digits

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

Round(x)

A

Rounds the number according to usual rules

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

Assignment statement

A

Left hand side, assignment operator, right hand side

Define new variable names, make point to values

Initialization statement, creates a new variable and assigns a value to it

Var = value

Y = ‘cat’

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

Multiple assignments

A

> > > x, y, z = 1, ‘two’, 3.0

> > > x
1

Etc

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

symbol

A

Comment or source code comment

Python ignores

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

Input function

A

Reads strings from the keyboard

If want numbers, then have to use subsequent int() or float() functions

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

How to capitalize?

A

X.capitalize()

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

How do you remove any unwanted white space characters?

A

Use strip() function

> > > ’ oven ‘.strip()
‘Oven’

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

What is stdout?

A

Standard output

Refers to the window where the text goes when printed, typically a simple text window.

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

What is stdin?

A

Standard input

Location from where the input function reads strings.

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

What is stderr?

A

Standard error

Refers to where the error messages are displayed.

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

What is the standard built in function for printing strings to the screen?

A

Print( )

> > > Print (‘Jack’, ‘ate’)
Jack ate

Or
»> print(‘jack’, ‘ate’, sep = ‘.’)
Jack.ate

Beeline character. \n

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

What are source code comments?

A

Notes in general, name of file, what it does, etc.

17
Q

Dir(m) function

A

Lists all of the functions in a module.