Python for Beginners - Part 4 - Conditional logic, Collection and Loop
Tags: python
Published: 2019-10-15 23:22:26

![python_titulo](https://thepracticaldev.s3.amazonaws.com/i/vgazyhifdrhnee7c31j9.jpg)

Fourth part of articles about the Microsoft's [Python for Beginners](https://www.youtube.com/watch?v=jFCNu1-Xdsw&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6) series.
All the examples from the playlist are available in this GitHub repository: [Python Examples](https://github.com/lucianopereira86/Python-Examples).

### Objective
You will learn how to work with conditional logics, collections and loops.
A Python file was created to demonstrate each example.

## Topics
* [conditional.py](#conditionalpy)
* [collection.py](#collectionpy)
* [loop.py](#looppy)

### conditional.py

Conditional logic examples.

![code13](https://thepracticaldev.s3.amazonaws.com/i/jjbzggme62evw6x7k7re.JPG)

Running the example:

```batch
python .\examples\conditional.py
```

The result:

![code14](https://thepracticaldev.s3.amazonaws.com/i/2bknqubd9ie03u0hvum2.JPG)

### collection.py

Manipulating arrays and lists.

![code15](https://thepracticaldev.s3.amazonaws.com/i/kzog03dgplfwolj9fbuh.JPG)

Running the example:

```batch
python .\examples\collection.py
```

The result:

![code16](https://thepracticaldev.s3.amazonaws.com/i/0yls2qdfn9n9en9vqqti.JPG)

### loop.py

Controlling loops.

![code17](https://thepracticaldev.s3.amazonaws.com/i/tpk38ciiixgffb8qio76.JPG)

Running the example:

```batch
python .\examples\loop.py
```

The result:

![code18](https://thepracticaldev.s3.amazonaws.com/i/2q516jk1owy4sxt5kpnp.JPG)

## Next
You will learn how to create functions, importing modules and creating virtual environments.

### Video References
* [Programming with Python | Python for Beginners [19 of 44]](https://www.youtube.com/watch?v=5pPKYWqkoek&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=19)
* [Programming with Python | Python for Beginners [20 of 44]](https://www.youtube.com/watch?v=zqVmqtTLmgw&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=20)
* [Programming with Python | Python for Beginners [21 of 44]](https://www.youtube.com/watch?v=oYaGJBMoXok&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=21)
* [Programming with Python | Python for Beginners [22 of 44]](https://www.youtube.com/watch?v=J9luo4cODzM&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=22)
* [Programming with Python | Python for Beginners [23 of 44]](https://www.youtube.com/watch?v=IBOHc87yFYw&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=23)
* [Programming with Python | Python for Beginners [24 of 44]](https://www.youtube.com/watch?v=Iui6K2STtbA&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=24)
* [Programming with Python | Python for Beginners [25 of 44]](https://www.youtube.com/watch?v=GWVrLL2BulM&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=25)
* [Programming with Python | Python for Beginners [26 of 44]](https://www.youtube.com/watch?v=WdKdGwYBUxg&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=26)
* [Programming with Python | Python for Beginners [27 of 44]](https://www.youtube.com/watch?v=LrOAl8vUFHY&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=27)
* [Programming with Python | Python for Beginners [28 of 44]](https://www.youtube.com/watch?v=rAvD-6MpTw4&list=PLlrxD0HtieHhS8VzuMCfQD4uJ9yne1mE6&index=28)