LPTHW Flashcards

1
Q

+

A

plus

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

-

A

minus

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

/

A

slash

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

\

A

backslash; encodes difficult-to-type characters into a string

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

*

A

asterisk

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

=

A

equals; assigns the value on the right to a variable on the left

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

[ ]

A

index operator; gives access to a sequence’s element (index of the item you want to access); must be an integer

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

{ }

A

used to embed variables in a string; must also starts string with f for format

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

print

A

prints the specified message to the screen, or other standard output device

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

def

A

defines a function

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

rewind

A

inbuilt function which is used to set the position of the file pointer to the beginning of the file

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

seek(0)

A

move the read/write location to the beginning of the file; seeks a specific spot in the file

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

readline

A

reads just one line of text

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

import

A

gains access to code in another module by importing it; it searches for the named module, then it binds the results of that search to a name in the local scope

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

close

A

closes the file; like File->Save

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

read

A

reads the contents of the file; you can assign the result to a variable

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

open

A

open a file using the file() type, returns a file object

18
Q

exists

A

returns if a file exists; add more

19
Q

input()

A

allows user input

20
Q

prompt

A

a string, representing a default message before the input

21
Q

truncate

A

empties the file; watch out if you care about the file

22
Q

write(‘stuff’)

A

writes “stuff” to the file

23
Q

len()

A

returns the length of a string

24
Q

round()

A

returns a floating point number that is a rounded version of a specified number, with specific number of decimals

25
float()
convert a string or number to a floating point number, if possible
26
>
greater-than
27
less-than
28
<=
less-than-equal
29
>=
greater-than-equal
30
+=
adds a value and the variable and assigns the result to that variable
31
%
modulus, get better definition
32
_
underscore
33
#
comment or pound character
34
==
tests whether two things have the same value
35
int()
return an integer object constructed from a number or string x, or return 0 if no arguments are given
36
pop()
removes the element at the specified position (the optional position allows you specific which element in a list to remove)
37
split()
splits a string into a list, specify the separator in the () commonly (‘ ‘)
38
sorted()
returns a sorted list of the specified iterable object; You can specify ascending or descending order. Strings are sorted alphabetically, and numbers are sorted numerically. Note: The string cannot contain both string and numeric values.
39
sys
This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter
40
f or format
formats the specified value(s) and insert them inside the string's placeholder; returns the formatted string
41
sys.argv
sys.argv is a list in Python, which contains the command-line arguments passed to the script