''' Purpose: demonstrate program user communication Author: Jim Cohoon Email id: jpc ''' # Send message to program user print() print( 'Hoos got your back' ) # Red squiggly lines usually denotes that you are trying to reference something that Python doesn't know! # Something not declared / not known in general print() # print() prints a blank line! print( 3007, '88', 88 + 4 ) # You can print any type / multiple types at once! # 3007 and the second 88 are ints (integers in Python) and '88' is a string # More on types to come! # You can do 3007 / 88 but not "3007"/"88" # Expression - a bit of code that ends up with a value (evaluates a value) Ex. 88 + 4 which is actually 92 print() print( "Hoos 'got' your back" ) # Printing '' (single quotes) in a string using double quotes on the outside # print( Hoos got your back ) # Without the quotes, Python says "what's Hoos got your back"???? # So we need the quotes to make sure Python knows it's a string! # print( "Hoos got your back" ) also works! Single quotes or double quotes! # Without quotes, print( Hoos ) Python will need you to define Hoos unless you put "Hoos" which says it's just a string # HEADER COMMENT # ''' ''' at the start of our program files indicate information about the code written in the file! # This starts the header comment with all the information at the start of the file ^ # Describes Purpose, Author, Email id! # - Starts a comment! (Comments are not code! They're not ran when you run a Python program!) # I will do this again later on but a quick shortcut to comment out multiple lines of code at once: # Highlight the code you wanna comment out and do Cntrl / on PC and Cmd / on Mac! # RUNNING CODE # (Many ways to do this) Right-click > Run the file or Run up at the top navigation bar ^^ # STRING # A sequence of characters # Ex. "CS1112", "Hello", "Welovecode", etc. # Can use single quotes or double quotes # 'hello' vs. "hello" # String is a built-in TYPE in Python - If it sees the single/double quotes it will know it's a string! # A lottttt more on strings later in the course! # HOMEWORK # Just involves printing what we want you to! # Please be sure to read the instructions in its entirety! # It should print to the console (the bottom part of the screen when you run it) # STYLE RULE YOU SHOULD FOLLOW FOR THIS CLASS :D # Professor Cohoon uses a Python style where he puts a space # after ( and before ) in a function # print( "whatwewannaprint" ) but print("whatwewannaprint") without spaces works too! # Style Rule - The way we write our Python code that won't cause the code to fail if we don't follow it # All of these notes will be posted in artifacts every class! # SYNTAX - REQUIRED - PYTHON NEEDS TO BE WRITTEN THIS WAY TO WORK # Python syntax requires built in function print() to be in lower-case. # Print() # This will not work! This is not according to Python syntax! # Python built-in functions like print() is all in lowercase! # Python functions have parentheses after the function. # functionname() is a function call '''Vocabulary (Notepad from class):''' ''' Many more of the vocabulary terms both covered and not covered in class can be found here: http://www.cs.virginia.edu/~cs1112/epistles/lexicon/ ''' # Algorithm - A set of instructions for solving a problem / recipe to solving a # problem # Program - An algorithm written in a particular programming language (for example # our Python programs will be algorithms executed in the language Python) # Programs are composed of statements! A statement is an instruction # telling the computer to do something (executable line of code) # Code - Contents of a Python file (individual statements make up the code!) # Grammar - Basically how we write the Python code / valid Python code that will # work # Syntax - Following the rules of the Python programming language - Syntax rules # must be followed! Ex. print() vs. Print() # RIGHT WRONG # Style Rule - How we write our Python code to make it readable (aesthetics / # organization the user can choose to write their code) - Breaking a style rule # will not cause the code to not work! # Ex. print( "Hello" ) vs. print("Hello") - Both work! :) # Header Comment - ''' ''' - Comment at the top of the program that describes # Purpose, Author, Email ID # Comment - # - Line of code that is not executed (useful for notes!) # Semantics - Meaning of the code / what the code does # Ex. print() will print whatever's inside the () into the console at the bottom! # Identifier - A word in the programming language as the name of something # Variables will be identifiers and typically store values / functionality # print is an identifier for the print() function that tells it to print to the console # Eventually when we do variable assignment, variables will be names that store variable # values. # _x1 = 2 (x is the identifier/name) # Identifiers must start with a letter (what follows can be letters/numbers)! # You can't do 1112CS as an identifier but can do CS1112 as an identifier! # _hello is an identifier too (underscore is a "letter") # So basically start identifiers with non-numeric characters! # A style rule is that none of your variables should start with _ (you can do it # but it's just more aesthetic / easier not to!) # Translate - Run lines of code to produce output (interpreting using Python language # so that the code we write can be interpreted to produce output by executing / running # each line one at a time) # Letter case - Ex. print() is all lowercase - print() will not work if you do Print() or PRINT() # Argument - information/values passed into functions in the parentheses to start it up # print() function can take in an argument # print( "Hello" ) - "Hello" is the argument!