


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



































5/12/
5/12/
5/12/ and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass yield def finally in print
5/12/ and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass yield def finally in print
5/12/ and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass yield def finally in print
Top-level components ◦ 8.1. Complete Pythonprograms ◦ 8.2. File input ◦ 8.3. Interactive input ◦ 8.4. Expression input 5/12/
y Java has:^ ◦ assignment statements ◦ for loops ◦ while loops ◦ do/while loops ◦ break ◦ if, else ◦ print ◦ return 5/12/
We haven’t talked about classes and objects(object-oriented programming or oop) y Object-oriented programming is oneparadigm for programming y Procedural programming is anotherparadigm for programming (we have beenusing Python in a procedural way; wewrite one Python statement afteranother) y Functional programming is anotherparadigm – where everything is a function(no loop; no assignment statements) 5/12/
y
y
y
y
5/12/
y In general, we can’t … y Alan Turing proved in 1936 that it is notpossible to write a program that can takeas input: a program and an input anddecide whether or not the program willfinish or will run forever. y This is called the “halting problem”. y Thus, we say it is “undecidable” 5/12/
5/12/
5/12/
y It is generally a bad idea to write one bigprogram that does everything. Why? ◦ People don’t want to read long programs ◦ Longer programs are (usually) more complexbecause some variables may be used in morethan one place; thus some parts of the programmay depend on others. y Given what we know so far in Python,…what language feature should we use?^ ◦ Functions! Each function can be written andtested. It doesn’t “see” variables except thosethat are input and those that it returns. 5/12/
y Top-down design^ ◦ Break the big program into a series of smallones. (Assume, for the moment, that you – orsomeone else – will be able to write thefunctions that you need.) 5/12/