Csci 1020 August 26, 2019 Program Assignment 1

Write a program in Python which finds out a user's name, asks for some numbers, then gives the user a friendly greeting demonstrating a fascinating (in your opinion) mathematical feat.

For programs in this class, you should submit your program as a plain text file with a “.py” extension and a name to help me know which program assignment it is for. A name like” is fine. Email me ( ) with your program as an attachment.

Your program itself should include commented lines at the very top within showing:
1) Your name
2) The date
3) A description of what the program does

Your program itself must run correctly. If you have trouble, you can email code to me with your questions.

Here is a sample program which exercises Python elements needed for the assignment.

# My Name   August 18, 2017  Program 1
# Calculate a final bank balance
from math import * 

name = raw_input("What is your name? ")
p = input("What is the amount of your deposit? ") 
y = input("How many years do you want to keep the account? ") 
r_percent = input("What is the annual percentage interest rate? ") 
k = input("How many compounding periods per year? ")
r = r_percent/100.0 # convert percent APR to a decimal 
balance = p*(1+r/k)**(k*y) 
print "=============================================" 
print name, ", your ending balance in dollars is", balance
Here is how you enter, save, and run your code using IDLE. The above code is used as an example.

1) Open IDLE.
You will see something like this below:

2) Select: File>>New Window
Below is what you see now.

3) Enter in your code
You will see something like this below, but somewhat different program code, of course.

4) Save this on the Desktop or other location, such as in a USB Drive, using "Save as".

I strongly recommend using short but descriptive names for programming assignments, say for this first programming assignment. Whatever you choose to name files, do not use spaces within file names. The first few lines of every program you write should have your name, the date, and a description of the program, so you can always find out what a program does even if the name is short. Short file names without spaces will make future assignments easier.

If you are using your own machine, I recommend creating a folder on your Desktop for each programming assignment, say program1 for this assignment.

If you are using a FDLTCC lab machine, or someone else's machine, you should save programs on your USB disk drive under a special folder there. If you do use the Desktop on a machine which is not your own, carefully copy your files onto your USB drive before leaving the machine. Files left on FDLTCC machines may be deleted at any time.

If you wish to use some sort of cloud storage, fine, but use a good naming strategy so that your files don't get lost. If possible, create a special folder to hold all program files for this source.

5) In the editor, run the program using: Run>>Run Module (F5)
The program executes in the shell, and you must answer the prompts using the shell. You enter name, amount, years, interest rate, and compounding periods, then the results are printed as shown below.


1) You will use your own formula and calculation for your program. Pick one which requires at least two numerical inputs. You can look around for scientific or financial formulas, and you can ask me (your instructor) about your ideas. For example, you could calculate the area of a field in square feet by asking for the width and length of the field. Problems with money are usually familiar.

2) The raw_input( ) function is used for strings, and input( ) is used for numbers.

3) There are two kinds of numbers in Python: integers and "floating point". The practical difference is that floating point numbers (also called "real") will always use a decimal, and integers will not use a decimal. Python will do automatic conversion/promotion from integer to floating point as needed, but some care is necessary else surprising/erroneous results occur. We will cover these in more detail later.

4) from math import *
This brings in math library code from the Python standard library. There are many Python standard libraries--included within your Python installation--and you have to include them when needed. You will be informed on which ones are needed and when. Typically, only a few are needed.

5) Assume that program users (us in class) will obey directions which the program itself gives! In short, if you require an integer, or a floating point with a decimal, instruct the user to do enter it correctly. Numbers entered with a decimal are floating point, and numbers without decimals are integers.

6) The standing rule is that you may exceed program assignments at any time! I recommend meeting the program assignment requirements first, just get the basic program done along with readings and postings, then later you should feel free to expand and craft programs as you wish and as time permits.
Content is neither approved nor reviewed by FDLTCC.