if Statement in Python

My friend and I graduated college the same year and went job hunting. He was always talking about how huge his skills are and how high in demand they are in the labour market. He rants that if he would ever sit for any job, they must be ready to pay him $5,000 monthly. I was more humble. I just want to get out of my parent’s sight for some hours.

We found a vacancy, and when we went in, my friend said that he would allow me to get the job if they offered him a job that pays lower than $5,000 and offers him vacation and allowance.

There are two conditions:

1. Salary must be $5,000 or more

2. the job must offer vacation and allowances.

This is the condition.

The if Statement

Almost all Python programs that involve decision-making use the if statement. The computer will execute the code when the script or situation meets the specified condition. This statement is written to tell Python that if this happens, do this. The statement can be a single line or a block of code.

This is what an if statement in Python looks like:

salary = 400
vacation = “2 days in a month”
if salary < 5000:
  print("I will reject the job")

There, we told Python if this is True, then do this. Now let us look at If…Elif..else Statement

Do you want to become an expert programmer? See books helping our students, interns, and beginners in software companies today (Click here)!

Leave a Comment

Python Tutorials