0% found this document useful (0 votes)
2 views14 pages

Lecture 2 - Loops

The document outlines various programming concepts in Python, including loops (infinite and for loops), input validation, and data structures like lists and dictionaries. It emphasizes the use of 'While True' for repeating actions and discusses nested loops. Additionally, it highlights the relationship between keys and values in dictionaries and how to iterate through them.

Uploaded by

RunningMan Haha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views14 pages

Lecture 2 - Loops

The document outlines various programming concepts in Python, including loops (infinite and for loops), input validation, and data structures like lists and dictionaries. It emphasizes the use of 'While True' for repeating actions and discusses nested loops. Additionally, it highlights the relationship between keys and values in dictionaries and how to iterate through them.

Uploaded by

RunningMan Haha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

Loop
2. While +

 If you are infinite loop, use Ctrl + C


3. For

 Name the value as _ so that it is indicting the counting times


4. Validating input +

 Assume the input is all positive and negative, we can use “While True”, it initiates a an
infinite loop, but we need a way to get out of this loop

 While True is a common paradigm in Python, when we want to do something again and
again
5. Iteration with list

6. len
7. Dictionaries +

 Key associates with the value


 Some associates with something
8. List of Dictionaries +
 Dictionary is just a collection of values, that allows us to associate the key with values
9. Nested Loop
9.1 Vertical

 The main does not need to know the print-columns function has changed
9.2 Horizontal

9.3 Square

You might also like