COSC 235: Programming and Problem Solving
February 2, 2009

Joseph D. Sloan
sloanjd @ wofford.edu


Class Introduction

Syllabus

Be sure you read this for general class policies.

Overall Class Goal: To be able to take a small to moderate sized problem, analyze that problem, break it into appropriate subtasks, and create a program (in Python) to solve the problem.

Website

You should visit this site on a regular basis. Watch for class summary links.

Software installation

We will be using software from www.python.org which can be freely downloaded and installed on your computer. However, this isn't required. The software is available in the computer lab.

Interpreted vs. Compiled languages

There are lots of exceptions, but very roughly: Compiled languages do the translation process once while interpreters retranslate code each pass though it. Complied languages tend to produce faster/more efficient code. Complied languages may require more coding effort and are less suited for experimental and exploratory programming. Complied languages make things easier for the computer; interpreted languages make things easier for the programmer.

Example of Interactive Code to Add Two Numbers

C++ Python
#include <iostream>
using namespace std;
int main ( void )
{
  int num1, num2, sum;
 
  cout << "Enter first number: ";
  cin >> num1;
 
  cout << "Enter second number: ";
  cin >> num2;
 
  sum = num1 + num2;
 
  cout << "The sum is: " << sum;
  return 0;
}

 

def add():
   num1 = input("Enter first number: ")
   num2 = input("Enter second number: ")
   sum = num1 + num2
   print "The sum is ", sum
 


This page was created by Joe Sloan.
It was last modified around: 02 February 2009 12:23 PM
Send mail to: sloanjd@wofford.edu