True and False and True False and False
- Slides: 73
ทบทวนความจำ True and False and True False and False True or False or True False or False not True False not False True 7
คำสงเงอนไข (if statement( ������ http: //www. ryt 9. com/s/prg/774090 10
ตวอยางคำสงเงอนไข (if statement(price = 40 if height <= 140: print('Hello Children!') price = 0 print('price =', price) height<=140 true print('Hello children') false price = 0 print('price =', price) 12
คำสงเงอนไข (if statement( • ������� condition false �� if condition: true statement 1 statement 2 : : statement n 13
การควบคมการไหลของโปรแกรม • โปรแกรมทใชคำสง height <= 140 if True e ls Fa ����� height = 160 120 price = 40 if height <= 140: print('Hello kids!') price = 0 print('price =', price) 15
ขอควรระวง • แนวคดเกยวกบบลอคเปนเรองสำคญ มากในภาษาไพธอน • ดงนนในการเขยนโปรแกรมควรตองระวงใน การยอหนา Ø แตเมอทำไปบอย กจะคนเคยไดไมยาก Fdskfjsdlkfslkdjfdsff fdskfsdflksdlkfdsf: fddslfldskf fdsfkdsfdsfd fdkfddfdfd fdkfdlf ๆ Good fdslkdskslkdjsld Fdskfjsdlkfslkdjfdsff fdskfsdflksdlkfdsf: fddslfldskf fdsfkdsfdsfd fdkfddfdfd fdkfdlf Bad fdslkdskslkdjsld 17
มมนกคด ตอนท 1 (ฟงกชน ( def num_candies(want, limit): if want < limit: return limit return want limit = 20 x = int(input("How many? ")) print("You should buy", num_candies(x, limit), "candies. ") 24
if – else statements ������ http: //splinedoctors. com/2009/02/hurry-up-andchoose/ 25
if - else statements • ���� if�� condition: • ��������statement T 1 statement T 2 (condition) ������: statement Tn ������ else: (statement) statement F 1 ������� T statement F 2 • �������� : (condition) statement Fn ������ 27
if – else statements • ������� �� if (condition) : true condition false statement T 1 statement T 2 : statement T 1 statement F 1 statement Tn statement T 2 statement F 2 else : statement F 1 : : statement F 2 statement Tn statement Fn : statement Fn 28
การควบคมการไหลของโปรแกรม n % 2 == 0 True print('It is an even number') e ls Fa print('It is an odd number') 30
ตวอยาง : ผลการสอบ (nestedif( �������� if score > 8: print("Good") score > 8 else: score <= 8 and score > 4 if score > 4: print("Passed") score <= 8 and score <= 4 else: print("Failed") score <= 4 39
ตวอยาง : ผลการสอบ (คำสง elif( if score > 8: print("Good") else: if score > 4: print("Passed") else: print("Failed") if score > 8: print("Good") elif score > 4: print("Passed") else: print("Failed") • โปรแกรมสามารถทำใหอานงายขนได ถาใชคำสง elif 40
if – else statements ������ http: //www. flickr. com/photos/29104098@N 00/285609610/ 41
if – else statements • if – else ใชในกรณทตอง การแบงเงอนไขใน การเลอกทำคำส งมากกวาหนงเง อนไข • ���� if�� condition 1: statement 1 elif condition 2: statement 2 elif condition 3: statement 3 : : : else: statement n 42
if – else true condition 1 false statements statement 1 true condition 2. . statement 2 • ������ if���� (condition 1) : statement 1 elif (condition 2) : statement 2 else : statement 3 false . statement 3 43
คำสงวนซำ ������ http: //gamedesignconcepts. wordpress. com/2009/07/02/level-2 -game-designiteration-and-rapid-prototyping/ 46
? Fa ls e โปรแกรมทำงานไดอยางไร count <= 8 True print('I like Bossanova') count = count + 1 50
คำสง while condition • ������ true ���� while condition: statement 1 statement 2 : statement z n false statement 2 : statement n 52
มมนกคด 6: โปรแกรม n = int(input()) total = 0 i = 1 while i <= n: total += i i += 1 print(total) 59
มมนกคด 6: ฟงกชน def sum_to(n): total = 0 i = 1 while i <= n: total += i i += 1 return total 60
มมนกคด 7: คำใบอก pwd = input("Enter password: ") while ___________: print("Sorry. ") ____________________ print("Correct. ") 63
มมนกคด 7: เฉลย pwd = input("Enter password: ") pwd != 'happy 204111' while ___________: print("Sorry. ") ________ pwd = input("Enter password: ") ________________ print("Correct. ") 64
มมนกคด 9 total = 0 n = 0 while n >= 0: n = input('Input n : ') if n >= 0: total = total + n print('total =", total) �������� ? ��������� n<0 72
- 102 dr
- False true
- Sound waves are electromagnetic waves. true false
- True vocal folds and false vocal folds
- Difference between true ribs and false ribs
- Accounting chapter 14 test
- Chapter 11 accounting test
- True or false: chemical and physical changes alter matter.
- Chapter 36 body measurements and vital signs
- 3/128 as a percentage
- All equilateral triangles are acute true or false
- Smoking quiz true or false
- Read the sentences and decide if they take the or not.
- True and false disciples meaning
- Fact and opinion sentences
- Ap psychology chapter 9 memory
- True or false: groundwater can flow.
- Which of these statements is false
- Rotation causes seasons true or false
- All quadrilaterals are polygons true or false
- Percent increase and decrease maze answer key
- Take away any liquid near your working area
- True or false: mla requires a title page.
- Boolean operators truth tables
- True or false questions about leadership
- Radiation travels in straight line. (true/false)
- Identify each statement as either true or false
- For each statement decide whether it is a function of the
- Chapter 41 telephone techniques critical thinking
- With block format all new paragraphs are indented
- Body language is a part of listening. true false
- установите соответствие true и false
- Grains are types of grasses. true false
- True/false: there are ten spanish-speaking countries.
- Tipe data bahasa pascal
- Yang termasuk tipe data perbandingan adalah
- True or false science questions
- Pub quiz true or false
- Geometry chapter 6 review
- Psychology true or false
- Quiz on road safety with answer
- Wanted a just right government cause and effect
- Dance is always done to music.
- True or false
- To kill a mockingbird jeopardy
- A sentence that is either true or false
- Sexual harassment quiz
- The possessive adjectives show ownership
- Activity 2 let's review
- Lesson 1
- True or false?
- What are the elements in music
- 4 choose the correct item
- Telephone techniques chapter 14
- True or false questions about cells
- El medio ambiente en mi comunidad
- All triangles are polygons true or false
- Leader often shares power with other parts of government
- The rules of the classroom true or false
- Credit unions are for-profit organizations. true false
- Xscript
- Framton sees a ghost. true false
- True or false questions on research methodology
- Reaction rate
- True-false physical activity clues answers
- Write true or false for each statement
- Finance true/false questions
- Chapter 3 true or false
- Moses 1:39
- Javajava
- True or false hot glass looks the same as cold glass.
- How to answer true or false questions
- True/false
- Kerala women wear fanek true or false