ITEC 109 Lecture 17 Conditionals Review Function examples
- Slides: 21
ITEC 109 Lecture 17 Conditionals
Review • • Function examples if / elif /else Questions? HW 1 due next Friday – One website Conditionals
Objectives • Learn the last two pieces of conditionals • Examples Conditionals
Traveling Do you want to visit Disney World or Jurassic Park Conditionals
Food Marketing campaign: You know you want to order a burger and fries Conditionals
Acquisition or Conditionals or and
And • Function that takes two Booleans and returns a Boolean • Represented by bool. A and bool. B in Python • Truth table bool. A bool. B Result of and True False True False Conditionals
Example x = read. Nuclear. Temperature(); y = read. Available. Cooling(); if ( x > 0 and x <= y): begin. Cooling(); else: sound. Alarm(); Conditionals
Conversio n x = read. Quantity(); y = get. Order. Description(); if ( y == “Sweater”): if (x > 5): print. Now(“Bulk pricing”); OR if ( y == “Sweater” and x > 5): print. Now(“Bulk pricing”); Conditionals Allows for nesting on 1 line
Or • Function that takes two Booleans and returns a Boolean • Represented by bool. A or bool. B in Python • Truth table bool. A bool. B Result of or True True False False Conditionals
Example x = get. Residency(); #0 #1 #2 if == Citizen == Green card == Visa (x == 0 or x ==1 or x ==2): print. Now(“You meet the requirements”); Conditionals
Chaining x = get. Flyer. Status(); if (x == 3): System. out. println(“VIP”); if (x == 2): System. out. println(“Standard”); if (x == 1): System. out. println(“VIP”); if (x ==1 or x == 3): System. out. println(“VIP”); if (x ==2): System. out. println(“Standard”); Conditionals
Scenarios • Website entering a password twice – Why? How do we enter it? • Picking courses from the Core – Core 1 = Art, Philosophy, English, History – Core 2 = Math, ITEC, Stat – How do we tell if you meet core 1 and core 2 requirements? Conditionals
Scenarios • Determine what letter grade to display for a numeric score • 90 ->100 = A • 80 ->89 = B • 70 ->79 = C • 60 ->69 = D • 0 ->50 = F Conditionals
Example x=0; y=3; z=4; z=z+x+y; if ((( z> y-x or x+z > y) and (x != x)): print. Now(“Am I printed? ”); Conditionals
Transistors Electricity Video card pin associated with X pixel on monitor Transistor Conditionals
Gates • Control over what goes out Electricity A B Only emits electric charge when A/B are at a specific voltage And gate Conditionals
Simple CPU • 4 basic operations, 2 inputs Add circuitry Multiply circuitry Divide circuitry A B Subtraction circuitry 2 to 4 Mux True Add True False Multiply False True Divide False Subtract Conditionals
Python CPU a = get. Input 1(); b = get. Input 2(); if (a and b): add(); if (a and not b): multiply(); if (not a and b): divide(); if (not a and not b): subtract(); Conditionals
Computer power • • And gate has 6 transistors Core 2 Duo has 291 million transistors 48. 5 million low level gates How we can do games at > 30 FPS Conditionals
Review • • And Or Syntax Examples Conditionals
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Projet itec terminale sti2d
- Itec 3010
- Itec 4010
- Itec 3220
- Zona de subduccion
- Itec 3220
- Itec 3220
- Itec 1000
- Itec 1000
- Itec 1000
- Itec 1000
- Itec 1000
- Itec 1010
- Itec exam results
- First-cut design class diagram
- Itec 1000
- Itec irrigation controller
- Itec 350
- Itec
- Itec
- Cs itec