LPTHW CH1 Flashcards

(28 cards)

1
Q

print

A

it prints out quoted strings in powershell.

Use “” or ‘’

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

What does # do?

A

cancels the line of code for commenting

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

What are the math symbols?

A
\+ add 
- subtract 
* mult
/ divide 
% percent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the greater and less than symbols?

A

> greater than
= greater and equal
I’m sad that your greater and equal

They will give the result of true or false

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

What do variables do?

A

It’s name for something. You can assign it a number, equation, or defined function

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

%s, %d, %r

Which is best for debugging?

A

Formatters replace a variable or value in the printed strings. If you want multiple, you need to use ( )

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

”””

A

allows you to print on unlimited lines of code

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

\t

A

tabs the code in

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

\

A

splits on a line; also put this in front of a quote to refrain from ending the print

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

\

A

allows for a single slash in the string

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

raw_input()

A

asks the user for an input

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

int(raw_input())

A

Converts the input from the user to a number

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

raw_input(“How old are you?”)

A

This prompts the user the question in the parentheses and asks for an answer

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

from sys import argv

A

from the sys module (library of code) import (takes it out of the library) argv (argument fx)

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

script, first, second, third = argv

A

there are three variables. You must pass three command line arguments

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

What’s the difference between argv and raw_input?

A

arguments you pass to your python script on command line when you run it. It unpacks them on command line.
While the script is running, raw_input() prompts the user for an input

17
Q

open

A

opens a file on command line

18
Q

read

A

reads a file on command line

19
Q

txt.read ()

A

reads the text file

ex) print txt.read(filename)

20
Q

close

A

closes file on command line

21
Q

target.write()

A

Allows you to write in a text when prompted on command line script.

22
Q

target.close()

A

closes the file

23
Q

truncates()

A

truncates a file

24
Q

from os.path import exists

A

Your importing exists from os.path module

25
exists
it checks to see if a file or directory exists
26
echo
makes a file on command line
27
cat
reads the text file
28
What 3 things a function does?
1. Names pieces of code 2. They take argument variables 3. make "mini-scripts" or "tiny commands"