CSS 115 - Programming Fundamentals 1 (Python) Fall 2024 Lecture 5 PDF

Summary

This lecture covers Python programming fundamentals, focusing on for and while loops. It includes syntax examples and explains how these different looping mechanisms work. The lecture is part of the CSS 115 course at SDU University, Fall 2024.

Full Transcript

CSS 115 - Programming Fundamentals 1 (Python) Fall 2024 Lecture 5 Plan Python statements Part 2: while loop for loop break & continue statements Questions For Loop Many objects in Python are “iterable” string, list, d...

CSS 115 - Programming Fundamentals 1 (Python) Fall 2024 Lecture 5 Plan Python statements Part 2: while loop for loop break & continue statements Questions For Loop Many objects in Python are “iterable” string, list, dictionary We can use for loops to execute a block of code for every iteration. Syntax: my_iterable = [1,2,3] for item_name in my_iterable: print(item_name) While Loops While loops will continue to execute a block of code while some condition remind True. Syntax: while some_boolean_condition: # do something While Loops combine with an else while some_boolean_condition: # do something else: # do something different Additional Lectures Python Iterations Questions

Use Quizgecko on...
Browser
Browser