python commands Flashcards Preview

PYTHON > python commands > Flashcards

Flashcards in python commands Deck (14)
Loading flashcards...
1
Q

pop function

.pop

var1.pop(var2)

.pop(var1)

A

Removes and returns an object from a list.

Calls the pop function.

from container var1, run pop function on var2
OR
Call pop function on parameter var2 which is in container var1

Call pop function on var1

2
Q

.split

split function

A

Calls the split function.

Makes each word in string a separate piece(objects/strings) of data, basically turns strings into lists.

3
Q

.append

append function

A

Calls the append function.

Adds to the end of a list.

4
Q

.join

join function

A

Calls the join function.

Joins all objects together from a list.

i.e. print ‘ ‘.join(chris)
will print: bread butter scones jam tea coffee
joins a specified range of objects together from a list
i.e. print ‘ and ‘.join(chris[3:6])
will print: jam and tea and coffee

chris [bread butter scones jam tea coffee].

5
Q

.exist

exist function

A

Calls the exist function.

Checks to see if a file/module exists and returns True if yes or False if no.

6
Q

.open

open function

A

Calls the open function.

Opens a file/module.

7
Q

.close

close function

A

Calls the close function.

Saves and closes a file/module.

8
Q

.read

A

Calls the read function.

Reads the contents of a file.

9
Q

.readline

deadline function

A

Calls the readline function.

Reads a specific line of file contents.

10
Q

.truncate

truncate function

A

Calls the truncate function.

Deletes all data in a file.

11
Q

.write

write function

A

Calls the write function.

Write to a file. overwrites existing data.

12
Q

.items

item function

A

Calls the items function.

Retrieves data associated with variables or whatever it is called on.

13
Q

.get

get function

A

Calls the get function.

Safely retrieves data that may or may not be there.

14
Q

.key

A

?