LPTHW CH1 Flashcards
(28 cards)
it prints out quoted strings in powershell.
Use “” or ‘’
What does # do?
cancels the line of code for commenting
What are the math symbols?
\+ add - subtract * mult / divide % percent
What are the greater and less than symbols?
> greater than
= greater and equal
I’m sad that your greater and equal
They will give the result of true or false
What do variables do?
It’s name for something. You can assign it a number, equation, or defined function
%s, %d, %r
Which is best for debugging?
Formatters replace a variable or value in the printed strings. If you want multiple, you need to use ( )
”””
allows you to print on unlimited lines of code
\t
tabs the code in
\
splits on a line; also put this in front of a quote to refrain from ending the print
\
allows for a single slash in the string
raw_input()
asks the user for an input
int(raw_input())
Converts the input from the user to a number
raw_input(“How old are you?”)
This prompts the user the question in the parentheses and asks for an answer
from sys import argv
from the sys module (library of code) import (takes it out of the library) argv (argument fx)
script, first, second, third = argv
there are three variables. You must pass three command line arguments
What’s the difference between argv and raw_input?
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
open
opens a file on command line
read
reads a file on command line
txt.read ()
reads the text file
ex) print txt.read(filename)
close
closes file on command line
target.write()
Allows you to write in a text when prompted on command line script.
target.close()
closes the file
truncates()
truncates a file
from os.path import exists
Your importing exists from os.path module