Girl Develop It Buffalo

PHP for Beginners Class 2 Exercises


Exercise 1

Make a variable called "temperature." Set your temperature variable to 20 degrees. Write some code that tells you to put on a coat if it is below 50 degrees.

Exercise 2

Modify your "wear a coat" code for these conditions:

  • If it is less than 50 degrees, wear a coat.
  • If it is less than 30 degrees, wear a coat and a hat.
  • If it is less than 0 degrees, stay inside.
  • Otherwise, wear whatever you want.

Exercise 3

Add a logical operator to your what to wear program.

Exercise 4

Write a loop that gives you the 9's times table, from 9 x 1 = 9 to 9 x 12 = 108.

Finish early? Try using a loop inside a loop to write all the times tables, from 1 to 12.

Exercise 5

Create an array of your friends and their favorite foods. Echo a few foods onto your screen.

Exercise 6

Take your array of friends and write a foreach loop that echos "My friend NAME likes FOOD."