nortonlyr / PythonFundamentals.Exercises.Part1

Slides:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Part 1

Accompanying resources

Exercise 1

  • Open Terminal.
  • Launch the Python interpreter.
  • Print a line that says "Hello Python".
  • Exit the Python interpreter.

Exercise 2

  • Using the Python interpreter, identify the data type for the following values:
    • True
    • 42
    • False
    • 1.5
    • "Python is fun"
    • "3.5"

Exercise 3

  • Using the Python interpreter, perform the following operations. Be sure to experiment with mixing intergers and floats.
    • Addition
    • Subtraction
    • Multiplication
    • Division
    • Floor division
    • Modulo
    • Exponentiation

Exercise 4

Create a Python script called first_name_500_times.py. Modify your script according to the instructions below.

  • Declare a variable called first_name with your first name as its value.
  • Print the value of first_name to the screen 500 times.
  • Save & execute the script.

Exercise 5.a

  • Using Terminal, make a copy of first_name_500_times.py and call it full_name.py
cp first_name_500_times.py full_name.py

Exercise 5.b

Modify full_name.py according to the instructions below.

  • Comment out the line where your first name was printed 500 times.
  • Create a variable called last_name with your last name as its value.
  • Create a variable called full_name whose value is the combination of the first_name variable and the last_name variable.
  • Print the value of the full_name variable.

Exercise 6

Create a Python script called fahrenheit_to_celsius.py

  • The script should declare a variable called fahrenheit.
  • The script should then convert the value of fahrenheit to celsius.
  • The conversion should be displayed on the screeen in the following format: "32 degrees fahrenheit is equal to 0.0 degree(s) celsius"

About

Slides:


Languages

Language:Python 100.0%