New Training: Conditionals and Loops in Python
| new skills - Team Nuggets

New Training: Conditionals and Loops in Python

In this 6-video skill, CBT Nuggets trainer Ben Finkel covers the first control flow elements of Python which are conditionals (if-then-else) and looping. Watch this new Python training.

Learn Programming and Development with one of these courses:

This training includes:

  • 6 videos
  • 55 minutes of training

You’ll learn these topics in this skill:

  • Conditionals and Loops in Python
  • Branching Code with Conditionals
  • Iterating Code with While Loops
  • Iterating Code with For Loops
  • Conditional and Loop Control
  • Creating the Game Hangman

How Do IF Statements Work in Python?

All programming languages have a way to control the flow of a program. The flow of an application is the path in which code will take based on certain criteria. Though some programming languages, like JavaScript, can be difficult to manage flow due to how those languages are designed, all programming languages use a basic syntax to control flow. They implement something called an IF statement. Python isn't any different.

An IF statement evaluates the value of a variable or object to determine whether an action should be performed. Here's an example:

IF (x == 0 ) THEN x=x+1

In this case, that IF statement is evaluating the value of X. If X equals zero, then it increases the value of X to one. We can also use an ELSE clause with that IF statement for additional actions. For instance, you could add an ELSE statement to the end of that IF statement to increment the value of X by two. So, if X is any other value than zero (EG. It has a value of one), the code will increase the value of X by two (EG. It will add 2 to the current value of one for X).



Ultimate DevOps Cert Guide

A 61-page guide to every DevOps, AWS, Azure, and Google Cloud certification, and how they fit into your career.

I have read and understood the privacy policy, and am able to consent to it.