If and else statements in Python

import modules

import pandas as pd
import numpy as np

create test variable

test = 25

simple if statement

if test < 50:
    print("Value is less than 50")
Value is less than 50

if else statement

dollars = 50
movie_cost = 20

if dollars > movie_cost: print("You can afford to go to the movie") else: print("You can't afford to go to the movie")
You can afford to go to the movie

Ace your next data science interview

Get better at data science interviews by solving a few questions per week

Learn more

Find a bug? Submit a suggested change on Github, or message me on Twitter.