Created
September 6, 2017 14:18
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thats really neat!