Skip to content

Latest commit

 

History

History
98 lines (79 loc) · 1.66 KB

File metadata and controls

98 lines (79 loc) · 1.66 KB

If

Write "if".

if

Next, add a space and a variable.

if apples

After that, add two equal signs.

if apples ==

If you want it equal to a integer, add a space and the integer. If you want it less than or equal to, add the appropriate signs. After that, put a colon. If you want to view the variable tutorial, click here

if apples == 1:

If you want it equal to a string, add a pair of parenthesis and inside it, put a string. After that, put a colon.

if apples == "alot":

Next, press enter and press tab. After that, put any code. In this case, I will put a print line. If you want to view the printing tutorial, click here

if apples == "alot":
  print("You have",apples,"apples")

Examples

Example 1:

apples = 1
if apples == 1:
  print("You have",apples,"apples")

Run:

You have 1 apples

Example 2:

apples = "alot"
if apples == "alot":
  print("You have",apples,"apples")

Run:

You have alot apples

Example 3:

apples = 1
if apples == 1:
  print("You have",apples,"apples")
apples = 2
if apples == 2:
  print("You have",apples,"apples")

Run:

You have 1 apples
You have 2 apples

Example 4:

apples = 1
if apples == 1:
  print("You have",apples,"apples")
  apples = 2
if apples == 2:
  print("You have",apples,"apples")
  apples += 1
if apples == 3:
  print("You have",apples,"apples")

Run:

You have 1 apples
You have 2 apples
You have 3 apples