Wednesday, January 8

Get Started. It's Free
or sign up with your email address
Wednesday, January 8 by Mind Map: Wednesday, January 8

1. Objects & types

1.1. If something is an object, it means it has three characteristics

1.1.1. 1. Attributes Characteristics, its content

1.1.2. 2. Zero or more names Ex. x = 5 x is the object, an attribute is that it has the value of 5

1.1.3. 3. Actions/operations Actions that can be done on/with the object (like division on a float/int)

1.2. Knowing the type of your object is important

1.2.1. You can do type(_) to find out the type of object something is, in case you don't know Ex. from circle program radius_int = int(radius_str) The functions int( ), float( ), and str( ) are called constructors They are used to make a particular object of that type You can combine these with the input function into one line

2. Branching (aka conditionals)

2.1. Allows your program to make a decision based on user input

2.2. Boolean

2.2.1. It is a binary decision value Meaning it evaluates to one of two options: True or False

2.2.2. Ex. x is greater than 5 This is a boolean expression because it is always either true or false

2.2.3. Options < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal != Not equal

2.3. Branching: You're going to write a statement where if it's true, you go down this path, and if it's false, you go down another path

2.3.1. The choice of executing one part of a program or another

2.3.2. Types Option 1) If statement 1 path Option 2) If-else statement 2 paths Option 3) If-elif-else statement 3+ paths Option 4) If-if Separate decisions

2.4. General

2.4.1. You always have to have an "if", at least You can have: If alone If + else If + elif (as many as u want) If + elif (as many as u want) + else

2.5. Nested conditionals

2.5.1. Making a second decision depending after a first decision is true Aka, check for another condition after a condition resolves to be true You may have any number of these nested as you want Ex.) if x > 0: print("positive number") --> if x % 2 = 0 print("even") else: print("odd")