mario - cs50 cdncdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while”...
TRANSCRIPT
![Page 1: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/1.jpg)
mario
![Page 2: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/2.jpg)
¨ prompt and validate user input ¨ draw the pyramid
TODO
![Page 3: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/3.jpg)
¨ prompt and validate user input ¨ draw the pyramid
TODO
![Page 4: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/4.jpg)
¨ get_int!¨ #include <cs50.h> !
¨ get_int!¨ import cs50
C Python
prompt user!
![Page 5: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/5.jpg)
do !{ ! // something happens !} !while (condition); !
C Python
validate input!
![Page 6: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/6.jpg)
while (condition) !{ ! // something happens !} !
while condition: ! # something happens !!
C Python
validate input!
![Page 7: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/7.jpg)
“do-while” loop
while True: ! # prompt user ! if condition: ! break !
executes at least once
![Page 8: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/8.jpg)
“do-while” loop
while True: ! # prompt user ! if condition: ! break ! checks
condition
![Page 9: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/9.jpg)
!if (bool1 || bool2) !!!if (bool1 && bool2) !
!if bool1 or bool2: !!!if bool1 and bool2: !
C Python
compound conditional expressions!
![Page 10: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/10.jpg)
þ prompt and validate user input ¨ draw the pyramid
TODO
![Page 11: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/11.jpg)
draw the pyramid ¨ for each row...
¤ print left pyramid n print spaces n print hashes
¤ print gap n 2 spaces
¤ print right pyramid n print hashes
# # ! ## ## ! ### ### ! #### #### ! ##### ##### ! ###### ###### ! ####### ####### !######## ######## !
![Page 12: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/12.jpg)
# print something with a newline !print("hello, world") !!# print something without a newline !print("hello, world", end="") !!# print something 50 times !print("#" * 50) !!# print newline !print() !
print() !
![Page 13: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/13.jpg)
þ prompt and validate user input þ draw the pyramid
TODO
![Page 14: mario - CS50 CDNcdn.cs50.net/2016/fall/walkthroughs/mario/more/python/mario-more.pdf“do-while” loop while True:! # prompt user! if condition:! break! executes at least once](https://reader034.vdocuments.site/reader034/viewer/2022050111/5f4909f1598f7f5d45081581/html5/thumbnails/14.jpg)
# # ! ## ## ! ### ### ! #### #### ! ##### ##### ! ###### ###### ! ####### ####### !######## ######## !
this was mario