Skip to content

Instantly share code, notes, and snippets.

@bmontana
Created September 6, 2017 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmontana/f8ca2c88adf27ddb8e0367ebd362655b to your computer and use it in GitHub Desktop.
Save bmontana/f8ca2c88adf27ddb8e0367ebd362655b to your computer and use it in GitHub Desktop.
This program prints a table of Celsius temperatures and their Fahrenheit equivalents from 0°C to 100°C.
# convert_5.py
#
# Author: Bill Montana
# Course: Coding for OOP
# Section: A3
# Date: 30 Aug 2017
# IDE: PyCharm Community Edition
#
# Assignment Info
# Exercise: 5
# Source: Python Programming
# Chapter: 2
#
# Program Description
# This program prints a table of Celsius temperatures and their Fahrenheit equivalents
# from 0°C to 100°C.
#
# Algorithm (pseudocode)
# Print table headings
# For Celsius temperatures from 0° to 100°, skip counting by 10
# Calculate corresponding Fahrenheit temperature
# Print Celsius and Fahrenheit temperatures in table
def main():
print("This program prints a table of Celsius temperatures and their Fahrenheit \
equivalents from 0°C to 100°C.")
print()
print(" Celsius\t Fahrenheit")
print(" -------\t ----------")
for i in range(11):
celsius = i * 10
fahrenheit = (celsius*2) * 0.9 + 32
print('\t{0:3d}\t\t\t{1:>5.1f}'.format(celsius, fahrenheit))
main()
@crapkoch
Copy link

crapkoch commented Sep 6, 2017

Thats really neat!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment