上游充通大学 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Chained Conditionals if x ==y: print x,"and",y,"are equal" elif x y: print x,"is greater than",y else: no yes print x,"is less than",y print x,"and",y,"are equal" 11
Chained Conditionals 11 if x == y: print x, "and", y, "are equal" elif x > y: print x, "is greater than", y else: print x, "is less than", y
上游充通大学 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Nested Conditionals if x ==y: print x,"and",y,"are equal" else: if x y: print x,"is less than",y 10 yes else: x =y print x,"is greater than",y end) 12
Nested Conditionals 12 if x == y: print x, "and", y, "are equal" else: if x < y: print x, "is less than", y else: print x, "is greater than", y
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Exercices ·def main(): x1,x2,x3 input ("please enter three values:" missing code sets max to the value of the largest print "The largest value is", max 13
Exercices • def main(): x1, x2, x3 = input("Please enter three values: ") # missing code sets max to the value of the largest print "The largest value is", max 13
上游充通大学 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Case 1 ==> yes 0 x1>=x2 yes 10 yes ×1>=x3 父2>=x3 no max x1 max x3 max x2 max x3 L 14
Case 1 14
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY Case 2&3 case 2: Compare Each to All if x1 >=x2 and x1 >=x3: max xl elif x2 >=x1 and x2 >=x3: max x2 else: max x3 case 3: Sequential Processing max x1 if x2 max: max x2 if x3 max: max x3 15
Case 2&3 15