

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Instructions for completing the first programming assignment in the ecs 10: basic concepts of computing course at uc davis. Students are required to write a python program that converts temperatures from fahrenheit to celsius and kelvin. Formulas, examples, and instructions for submitting the assignment online. It also suggests resources for getting started with the idle programming environment.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


ECS 10: Basic Concepts of Computing Spring 2007
Overview. In this assignment you will write your first Python program. Your program should take as input a temperature in degree Fahrenheit (◦F) and then output the equivalent temperature in degree Celsius (◦C) and in degree Kelvin (◦K). In order to compute the desired output, given only the input, you need to know the algorithm. In this case, we just need two simple formulas for converting from degrees Fahrenheit degrees into the other temperature units. Here is the formula for converting from F degrees Fahrenheit into C degrees Celsius:
C = (F − 32) ∗
Note that Python makes a difference between, e.g., 5 and 5.0 (see the lecture notes from class). Thus you might have to “tweak” this formula a bit to get the intended result in Python. From the degrees Celsius C it is easy to compute the degrees Kelvin K as follows:
K = C + 273. 15
For example, the freezing point of water is 32 ◦F, or equivalently 0 ◦C or 273. 15 ◦K. On a really hot summer day in Davis, the temperature might be 104 ◦F, or equivalently 40 ◦C (or 313. 15 ◦K). Here is an example output that your program might produce:
Please enter a temperature in degrees Fahrenheit? 104 104 degrees Fahrenheit are ... 40.0 degrees Celsius and 313.15 degrees Kelvin.
What is written in boldface (here: 104 ) is what the user has entered. Everything else is output by the computer. The symbol >>> indicates that the Python is ready to accept new commands.
Where to do the assignment. You can do this assignment either in the computer classrooms^1 or on your own computer, if you have one. To do the assignment on your own computer, you will need to install Python. We strongly recommend you install Python, and we strongly recommend that you do it ASAP. If you have a laptop, you could bring it to lab hours and we would be happy to help you install Python.^2 Either way, we suggest you begin by making a new folder on your Desktop, called ECS-10, where you can keep your work. To do this, put the mouse on an empty spot on the Desktop and right click, select New and then Folder. When the folder appears, its name should be highlighted; type ECS-10 to rename it.^3
(^1) See http://daks.ucdavis.edu/˜ludaesch/ECS-10-S07/labs.html (^2) See http://daks.ucdavis.edu/˜ludaesch/ECS-10-S07/software.html (^3) These instructions are for Windows. For Mac or Linux systems, apply the corresponding steps.
Getting started. We will demonstrate the use of the IDLE programming environment in class and in the discussion sections (see the course page for your discussion section). You should also plan to attend some of the lab hours where you can ask the TA or instructor for help with installing Python, using the IDLE environment, and generally with questions on your assignment. The following is a good online resource to get started with the IDLE environment:
http://hkn.eecs.berkeley.edu/˜dyoo/python/idle_intro/index.html
If you view this file with a PDF viewer, you should be able to click on the link. Alternatively, you might want to google with IDLE toying as keywords.
Handing in the program. We will use myUCDavis to hand in all assignments: In your browser enter my.ucdavis.edu and select ECS 10 from your list of courses on the right. Left-click Assignments near the upper left, and then Homework 1. Click on Drop-Off and then Browse. Go to your Desktop, and then to the ECS 10 folder you made, and finally select your program file, which should be of the form LASTNAME Firstname HW1.py (replace with your actual lastname and firstname). Once your file LASTNAME Firstname HW1.py appears in the box next to the Browse button, you can click Drop-Off to hand in your program.
Saving your work. If you are working on your own computer, you can just leave the ECS 10 folder on your Desktop for the rest of the quarter. If you are working in the computer classrooms, you will need to take the folder with you on your flash-drive. Plug the flash-drive into the computer (the staff in the computer classrooms can help you figure out how), open the flash-drive, and copy the whole ECS 10 folder onto it by moving the folder from the Desktop onto the flash-drive. Instead of using a flash-drive you can also save your work in your personal myUCDavis space.