Advertisement
Mars83

2-4

Oct 3rd, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #! /usr/bin/env python3.2
  2. # -*- coding: utf-8 -*-
  3.  
  4. # main.py
  5. """ Task: Exercise 2.4
  6.    Assume that we execute the following assignment statements:
  7.    width = 17
  8.    height = 12.0
  9.    For each of the following expressions, write the value of the expression
  10.    and the type (of the value of the expression).
  11.    1. width/2
  12.    2. width/2.0
  13.    3. height/3
  14.    4. 1 + 2 * 5
  15.    Use the Python interpreter to check your answers.
  16. """
  17.  
  18. # Main
  19. width = 17
  20. height = 12.0
  21. print("width = 17\nheight = 12.0") # \n = CRLF (new Line)
  22. print("width/2: " + str(width/2) + ", Type: " + str(type(width/2)))
  23. print("width/2.0: " + str(width/2.0) + ", Type: " + str(type(width/2.0)))
  24. print("height/3: " + str(height/3) + ", Type: " + str(type(height/3)))
  25. print("1 + 2 * 5: " + str(1 + 2 * 5) + ", Type: " + str(type(1 + 2 * 5)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement