






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Key points in this Introduction to Computing Using Python lecture are: Card Tricks, Quick Poker Primer, Probabilities, Monte Carlo Methods, Start Implementing, Python Features, Multi-Way Comparisons, Boolean, Special Methods, Boolean to Integer Conversion . Objectives of this course are: 1.Fluency in (Python) procedural programming 2. Competency in object-oriented programming 3. Knowledge of searching and sorting algorithms
Typology: Slides
1 / 12
This page cannot be seen from the preview
Don't miss anything!







§ 2 of same rank: pair (e.g., 3C 3D 5D 6H 7S) § 3 of same rank: three of a kind ( 5C 5D 5H 6H 7S) § 4 of same rank: four of a kind ( 6C 6D 6H 6S 7S) § Two separate pairs: two pair ( 5C 5D 6D 6H 7S) § 3 of one rank, 2 of another: full house ( 5C 5D 6D 6H 6S ) § All cards in rank sequence: straight ( 5C 6D 7D 8H 9S ) § All cards of same suit: flush ( 5H 7H 8H 10H KH ) § All in seq. and same suit: straight flush ( 5D 6D 7D 8D 9D )
multi-way comparisons x < y < z means x < y and y < z w == x == y == z means w == x and x == y and y == z One difference: middle operands are not evaluated twice. conversion to Boolean in conditionals 4.0 + 2 automatically converts 2 to float if x: … automatically converts x to bool. if n: means if n != 0: —for numeric types: zero is false, nonzero true if lst: means if len(list) != 0: —for sequence types: empty is false, nonempty true
augmented assignment x += y is shorthand for x = x + y One difference: expression on the left is not evaluated twice. special methods str and repr We have seen the special method str that is called to generate a readable string representation of an object. There is also repr which does something similar. str is used by str() and print. Meant for the user to read. repr is used by repr(), the interactive prompt, and back- quotes (x). Should be unambigous, for the programmer. Ideally, repr() returns exactly what you would put in your program to create that value—recall how strings work.
Boolean to integer conversion Conversions involving bool go both ways. When you convert a bool to a numeric type, True is 1 and False is 0. Example: x += (y > 3) increments x by 1 if y is greater than 3.
Casino de Monte Carlo in Monaco. Wikimedia commons / Wigulf "