# Using Compound Conditional Expressions

Practice Labs Module
Time
6 minutes
Difficulty
Intermediate

Welcome to the Using Compound Conditional Expressions Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

Join over 3 million cybersecurity professionals advancing their career
Sign up with
or

Already have an account? Sign In »

Overview

### Introduction

Welcome to the Using Compound Conditional Expressions Practice Lab. In this module, you will be provided with the instructions and devices needed to develop your hands-on skills.

### Learning Outcomes

In this module, you will complete the following exercise:

• Exercise 1 - Using Compound Conditions

After completing this lab, you will be able to:

• Use compound conditional expressions in Python programs

### Exam Objectives

The following exam objectives are covered in this lab:

• 2.1 Construct and analyze code segments that use branching statements

### Lab Duration

It will take approximately 15 minutes to complete this lab.

### Exercise 1 - Using Compound Conditions

As the name suggests, compound statements contain other statements within them, the execution of which is affected or controlled by the main statement.

For example, given below is the syntax of if compound statement:

if expression:

suite 1

elif expression:

suite 2

else:

suite 3

As you can see in the above example, compound statements consist of one or more clauses. The clause headers of a particular compound statement are all at the same indentation level; for example, if…elif…else. The elif header can be repeated multiple times. Depending on the condition that becomes true, a suite will be processed. Each suite can further contain nested compound statements.

The types of compound statements can be formed using the while, for, try, and with statements.

Functions and class definitions are also the examples of compound statements.

In this exercise, you will learn to write a program using the if compound statement.

### Learning Outcomes

After completing this exercise, you will be able to:

• Use compound conditional expressions in Python programs
Learning Partner
Comprehensive Learning

See the full benefits of our immersive learning experience with interactive courses and guided career paths.