after the BBC TV Show “Monty Python’s Flying Circus” - Simple and minimalistic compared to other programs - It’s almost like English - Free and Open Sourced - Powerful
new line every time you write a new step - For every block of code that is related to one step, you should indent and start a new line - All of this also help keep your code neat
numbers, text, lists of numbers and text, and etc. - Has a name that you give it - Must be unique - It’s like a labeled box that is used to contain other stuff
and underscore. - Cannot start with a number - Spaces are not allowed - Use underscore instead - Do not use python keywords and function names as variable names - Variable names should be short but descriptive
to display to someone. - Ex. print(Hello World!) - Hello world! is the String - You can have an empty String - 0 characters but it exist - Position # of a String - Hello World - H = 0 - d = 10 - Space = 5
the arrangement and order of words in your code - You did something Python did not expect - EOL means end-of-line - Your program stopped at the end of the line and did not find a double quote to close the string Try and see what other errors you can get by messing up the syntax
• Example: Bob = 100 • print(“Bob = 100”) • Or • bob = 100 ß the variable you already stored • print(“Bob had this amount of money =“ + str(bob)) ◦ turns your number into a string
calculate a math equation over and over again • Ex. Finding the area of many different rectangles from a list: ◦ Math problem: Find the area of the following rectangles 5 by 5 6 by 8 150 by 93 43 by 29.3 Def area(x, y) : return x*y
one place, whether you have just a few items or millions of items ◦ Can put strings, numbers, a lot of things ◦ You can name them too like how you name variables ▪ Name them pural words like bicycles, cats, dogs • Very important. Will use list a lot in coding
that contains numbers, you don’t need the quotations • List of strings need “ ” List1 = [1, 2, 3, 4] - You can also multiply a list by a number. Try multiplying list1 by 5 and print it out
it has a positions number • The position number starts at 0 ◦ Usually the case for most programming languages bicycle = [‘trek’, ‘cannondale’ , ‘redline’ , ‘pedal’] If you want to print the first element in the list, you would do this: print(list_name [ the number ]) print(bicycle[0])
Make a list of names • Print the 3rd name on your list • Also print “The third person’s name is ” before the name, on the same line ◦ Bonus if you store the previous message as a variable before you printed it
• Back in the days, computers looked like this: • Admiral Grace Hopper, while working on a computer like this, found a moth stuck inside which caused the computer to not work - called it “debugging” the system - the term caught on
need to debug • Use Print statements ◦ Print a line a code after each step you ask the computer to do ◦ When it’s not printing or it prints something wrong, that’s where the mistake is ◦ Helps you see and find where your program stops working
• Take notes • # ◦ Anything after the # will be turned into a comment ◦ That means it computer ignores and doesn’t read what is commented out in your code ◦ you can read it in the code, the computer can’t
position of the item you want to remove: • del list_name[index#] • Or list_name.pop(index#) • If you want to remove the last item (sometimes you don’t know how long a list is) • List_name.pop() What do you get? To store it: motorcycles = motorcycles.pop() print(motorcycles)
to delete an item from a list and not use the item in any way, use the del statement • If you want to use an item as you remove it, use pop() ◦ You can store a popped item into a variable
position of the value you want to remove • list_name.remove(‘nameofthingtoberemoved) • Everyone make a list of names, but include the name Bob in the list • Remove Bob’s name using the remove function
or tuples) • Map has a key and a corresponding value ◦ One key works with one lock ◦ Same thing for maps ◦ You use a key to get through the lock / You use a key to get to the value
of yes or no questions • For example, we can ask, are you older than 20? ◦ If yes, respond with, “You are too old” ◦ If no, respond with, “You are young!”
• None variable = None print(variable) None Then you should be able to do this, variable == None: print(“there’s nothing here”) The variable does not have a value