First Programs: Using Variables

  1. Open PyCharm, and create a new project called “FirstPrograms”.
  2. Right-click and create a new python file called hello_me.py
  3. Double-click the file to open it.
  4. Edit the file:
    1. Create a variable to store your first name
    2. Print “Hello, my name is …” and replace the ellipsis (…) with the variable that is storing your first name.
    3. Add a comment at the top of the file that explains what your program does.
  5. Run your python program.
  6. Create a second program called tips.py, that:
    1. Has 4 variables:
      • meal: holds the value of the meal ($53.48)
      • tax: holds the tax percentage (7%)
      • tip: holds the tip percentage (18%)
      • total: holds the total of the meal. Proper tipping technique dictates that the tip should be calculated based on the total cost of the meal, before tax is applied.
    2. Prints the contents of the total variable with a leading dollar sign ($).
  7. Run your tips program. The total should be $66.85