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

1.1.1.1. Characteristics, its content

1.1.2. 2. Zero or more names

1.1.2.1. Ex. x = 5 x is the object, an attribute is that it has the value of 5

1.1.3. 3. Actions/operations

1.1.3.1. 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

1.2.1.1. Ex. from circle program

1.2.1.1.1. radius_int = int(radius_str)

1.2.1.2. The functions int( ), float( ), and str( ) are called constructors

1.2.1.2.1. They are used to make a particular object of that type

1.2.1.2.2. 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

2.2.1.1. Meaning it evaluates to one of two options: True or False

2.2.2. Ex. x is greater than 5

2.2.2.1. This is a boolean expression because it is always either true or false

2.2.3. Options

2.2.3.1. <

2.2.3.1.1. Less than

2.2.3.2. >

2.2.3.2.1. Greater than

2.2.3.3. <=

2.2.3.3.1. Less than or equal to

2.2.3.4. >=

2.2.3.4.1. Greater than or equal to

2.2.3.5. ==

2.2.3.5.1. Equal

2.2.3.6. !=

2.2.3.6.1. 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

2.3.2.1. Option 1) If statement

2.3.2.1.1. 1 path

2.3.2.2. Option 2) If-else statement

2.3.2.2.1. 2 paths

2.3.2.3. Option 3) If-elif-else statement

2.3.2.3.1. 3+ paths

2.3.2.4. Option 4) If-if

2.3.2.4.1. Separate decisions

2.4. General

2.4.1. You always have to have an "if", at least

2.4.1.1. You can have:

2.4.1.1.1. If alone

2.4.1.1.2. If + else

2.4.1.1.3. If + elif (as many as u want)

2.4.1.1.4. 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

2.5.1.1. Aka, check for another condition after a condition resolves to be true

2.5.1.2. You may have any number of these nested as you want

2.5.1.3. Ex.) if x > 0: print("positive number") --> if x % 2 = 0 print("even") else: print("odd")