Outline for September 29, 2025
Reading:
§1, 2
Assignments:
Homework 1, due October 15, 2025
About the class
Instructor
Class web site, handouts
Canvas and submitting homework
Homework, grading, and extra credit
Python
What is Python?
Why Python for this class?
Compilers, assemblers, interpreters
Python, files and shells
Python: programming
language
that you use to tell the computer what to do
Shell: what you can type Python statements directly into, to see what they do
IDLE: the program that
interprets
Python statements (executes the Python program)
File: type Python statements into this, and then have IDLE execute those statements by running the program in the file
Jupyter, Anaconda, and Spyder
First program: hello, world [
hello_world.py
]
How to write a program; example is making change [
make_change.py
]
Goal and general algorithm idea
Representing data and basic program structure
Translating this into a programming-like language
Translating that into Python
Defensive programming and debugging
Assignment [
swap.py
]
Simple assignment:
variable
=
expression
Simultaneous assignment:
variableA
,
variableB
=
expressionA
,
expressionB
Exception
NameError
— local or global name is not found
Example
Compute the hypotenuse of a right triangle [
hypotnoex.py
,
hypotnoex1.py
]
Handle input problem [
hypotex.py
]
Exception
SyntaxError
— Python parser encountered a malformed statement
Exception
ZeroDivisionError
— attempt to divide (or take the remainder of) something by 0 [
divby0.py
,
divby0ex1.py
]
The difference between strings and integers [
twoplustwo.py
]
Difference between
’2 + 2’
,
2 + 2
Exception
TypeError
— operation or function applied to operand of wrong type
Typing letters when a number is expected [
divby0ex2
]
Type converter functions
int
,
float
,
str
String operators
Operator
+
: string concatenation
Operator
*
: repetition
Input [
make_change.py
]
input(prompt)
prints prompt, waits for user
When user hits enter, it returns what was typed as a string
Basic output [
printend.py
]
print(
a
,
b
, ...)
end=’XXX’
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email:
mabishop@ucdavis.edu
MHI 289I, Programming in Health Informatics
Version of September 29, 2025 at 11:17AM
You can also obtain a PDF version of this.