Variable Exercises

1.

Change just one line of the code below so it produces the following output when run.

xyz123
xyz123 xyz123
xyz123 xyz123 xyz123

 

2.

The initial code below prints a pattern of "dun" when run. Change just two lines of the code below so it produces the following output when run.

GO
GO Stanford!
GO Stanford! @
GO Stanford!
GO


 

3.

For this problem, you will write code from scratch. Write code that prints the following with your name instead of "Alice".

Hello, my name is Alice
Alice is in this class
Without a doubt Alice is working on this homework

Rather than mentioning your name directly, assign a variable to hold your name (i.e. x = ... ; ), then use that name variable within the print statements to insert your name. It should be possible to assign a different string to the variable, "Bob" or "Abby" or whatever, and then that name will appear in the printout when run.


 


Each click of a Run button saves that code on the computer running the browser. The button below retrieves the all code exercises listed to the right of the button.

count 3 : code-2-ex1 code-2-ex2 code-2-ex3

(code appears here)