04 Flashcards

1
Q

What are the two ways a programmer interacts with python?

A

Through the command line or by saving the source code to a file and instructing python to run the file

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

What is the first line you enter for a python script?

A

!/usr/bin/env python

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

A __________ is a named memory space used to store, access, and manipulate a variety of data objects.

A

variable

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

Python is dynamically typed T/F?

A

True

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

Python
__________ returns the data type of the obejct passed
___________ Exits the Python script and returns the exit status of the terminal
_________ Displays the help page from the Python Documents
_________ Returns the number of elements in a container, like a list or string
__________ Displays a list of all avaliable methods for the object passed

A

type(>object>)

exit(>object>)

help(>object>)

len(>object>)

dir(>object>)

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

What is the order of operations in Python?

A

PEMDRAS
Parenthesis, Exponents, Multiplication, Division, Remainder, Addition, Subtraction

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

The ______ function in python prompts the user for input and then prints ti to the screen

A

input()

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

____________ enables the programmer to change the data type to the desired operator

A

typecasting

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

Python
_____________ Attempts to convert the provided object into a string
_____________ Attemp[ts to convert the provided object into an integer
_____________ Attempts to convert the provided object into a float
_____________ Returns a sequenced list of elements from the iterable object passed

A

satr(>object>)

int(>object>)

float(>object>)

list(>object>)

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

The ______ stores an array of objects
They can store any type of data T/F?

A

list
True

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

Python

____________ appends an object to the end of a list

____________ removes the first element from the list specified by the obejct value

____________ Delete an element via index position

___________ sorts all the items and updates the list at the same time

______________ returns the index position of the first item located within the list equal to the object value
(tells you where something is in a list

A

list.append(>object>)

list.remove(>object>)

list.pop(>index>)

list.sort()

list.index(>object>)

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

Python

_________ returns a copy of the string with each letter capitalized

_________ returns a copy of the string with each letter in lowercase

_________ Returns the first index position where the substring is found. Return -1 if the substring is not found

__________ Returns the string as a list of delimited by the value passed as an argument, with a default of a whitespace.

__________ Returns a string composed of each item in the list concatinated by string

__________ Returns the string with leading and trailing chars removed; default is whitespace characters

A

string.upper()

string.lower()

string.find(<substring>)</substring>

string.split()

string.join(<list>)</list>

string.strip([chars])

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

How do I make it so my python string can contain variables?

A

f literal

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

The ___________ is the backslash charcter (). The escape charcter adds or removes meaning to or from the immediately follwing character

A

escape character

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

Pythons ________ function send information to the monitor

A

print

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

What is each attribute in pythons print function?

__________ List of objects to be printed, separated by commas.

__________ specify how to separate each object in the list. Default is <space></space>

_________ Specify what to print after all objects in the list have been printed. Default is new line

_________ Specify an output stream too write to. Default is sys.stdout

___________ Boolean specifying if the output is buffered or not

A

objects(s)

sep=’ ‘

end=”\n”|

file=fileobject

flush=false

17
Q

What are used to terminate condition statements in python? exp. if blue == 0”?”

A

:

18
Q

_________ allows programs to create, read modify, and delete files within directories

The ___________ method allows you to request an hande from the OS opening the file

The __________ method flushes any unwritten data and closes the object

A

File I/O

file.open()

file.close()

19
Q

What are the file modes for File I/O?

____________ read mode

____________ write mode

____________ append mode

___________ used in conjunction with any of the modes mention above to open non-text files

A

“r”

“w”

“a”

“b”