Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Introduction to if Statement | Python if Statement
course content

Зміст курсу

Conditional Statements in Python

Introduction to if StatementIntroduction to if Statement

Hello, everyone! I'm delighted to welcome you to this course. Here, we will become familiar with the conditional operator, sometimes referred to as the branch operator.

Let's clarify a bit:

Here, we have the following condition: age > 18. In our case, age = 20, and because 20 is greater than 18, the condition is True. So, the code inside the if block is run, and we see the message "You can vote". We learned a little bit about the conditional operator, and now let's strengthen our knowledge with simple practice. In the next chapter, we will study the syntax of this construction in more detail.

Example:

Analysis:

In this case, we have the following condition age > 18. In our case, age = 20, and since 20 > 18, the condition is True, so the code that is written in the if statement block is executed, and as a result we see "You can vote". We got a little acquainted with the conditional operator, let's strengthen our knowledge with simple practice, and in the next chapter, we will study the syntax of this construction in more detail.

Example

Завдання

  1. You have the following string: string = 'codefinity';
  2. Count the length of this string and write the result to the variable len_of_string;
  3. Write if statement that checks for the following condition: if the string length is greater than 7 , print the following text: Codefinity is the best platform to start your career in IT.

Fill in the blanks in the code you've already been given.

Once you've completed this task, click the button below the code to check your solution.

Все було зрозуміло?

Секція 1. Розділ 1
toggle bottom row
course content

Зміст курсу

Conditional Statements in Python

Introduction to if StatementIntroduction to if Statement

Hello, everyone! I'm delighted to welcome you to this course. Here, we will become familiar with the conditional operator, sometimes referred to as the branch operator.

Let's clarify a bit:

Here, we have the following condition: age > 18. In our case, age = 20, and because 20 is greater than 18, the condition is True. So, the code inside the if block is run, and we see the message "You can vote". We learned a little bit about the conditional operator, and now let's strengthen our knowledge with simple practice. In the next chapter, we will study the syntax of this construction in more detail.

Example:

Analysis:

In this case, we have the following condition age > 18. In our case, age = 20, and since 20 > 18, the condition is True, so the code that is written in the if statement block is executed, and as a result we see "You can vote". We got a little acquainted with the conditional operator, let's strengthen our knowledge with simple practice, and in the next chapter, we will study the syntax of this construction in more detail.

Example

Завдання

  1. You have the following string: string = 'codefinity';
  2. Count the length of this string and write the result to the variable len_of_string;
  3. Write if statement that checks for the following condition: if the string length is greater than 7 , print the following text: Codefinity is the best platform to start your career in IT.

Fill in the blanks in the code you've already been given.

Once you've completed this task, click the button below the code to check your solution.

Все було зрозуміло?

Секція 1. Розділ 1
toggle bottom row
some-alt