Learn Python 3 the Hard Way – What do you know so far?

 “There is no failure, only trying.”

Ok Let’s try to make a list of symbols, see how well I understand and recall their functions. It’s going to be tedious but the end goal is to create a reference table with my own words, which can help me review in the long term.

#Hash, Mesh or octothorpeTo comment out a piece of code, or make a note for future reference
printShow a statement or string on the screen
‘’Single quoteFor short string
“”Double quoteFor longer string
“”” “””Triple quoteFor paragraph
variableA value container, we store data in them
(f”)String formatA convenient way to write string with variable in a print functionEx:
print(f”If I add {age}, {weight}, and {height} I get {total}.”)
.format()Single FormatFormat a specified value and insert them inside the string’s placeholderEx:hilarious = False (A boolean value)joke_evaluation = “Isn’t that joke so funny?! {}“print(joke_evaluation.format(hilarious))
\nLine break escapeTo put a linebreak between lines in a string
\tTabbing escapeTo indent a string
\splitSplitting escapeTo split a string
\\Double backlash escapeTo print out a backlash in a string
input()Input methodTo prompt user to input value
int()Integer converter methodTo convert a string to integer value for mathematical usages
argvArgument VariableTo capture variable, unpack and assign values by the user to the variable names assigned to ARGV
open()Open methodTo take filename & return file object
read()Read methodTo access file object & return content
close()Close methodTo close the opened file
open(filename, ‘w’‘w’ = write only modeWrite or overwrite content of an existing file (it will automatically truncate content first)
.truncate()TruncateTo wipe out content in an existing file object
.writeWriteTo write content in a file
existsExistTo check file’s availability in boolean format
len()LengthTo return the length of the string
defkeywordTo denote a method’s definition
+=Positive incrementAdd to existing variable value.  (variable +=  1 is the same as variable = variable + 1 )
returnReturn statementTo send the function’s result back to the caller.
.seekLook methodTo find a specific place by byte in the file’s contentsEX.seek(0): get to the first character of the string

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s