



























































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!




























































DA_401/501/CSC 430_ Spring 2024
(^) Part I Closed-book, Paper pencil part (60%. 60 Minutes) (^) Part II Open book, Coding part (40%, 90 Minutes)
Mid-Term Next Lecture Time
Common Program Concepts (not only python)
Keywords reserved for Python
Variables
◦ (^) case sensitive, ◦ (^) Valid names: letters and numbers, _, no space, no special symbol, not start with a number, (no keywords, be meaningful).
◦ (^) Integers: x = 10 ◦ (^) Floating: pi = 3. ◦ (^) String: name = “I’m a student”, empty =““ ◦ (^) Boolean: quit = True, play = False
Arithmetic
Comparison Operators ◦ (^) <, <=, >, >=, ==, != Logical Operators:
Operators:
◦ (^) if: for exceptional ◦ (^) if-else: for two choices. ◦ (^) If-elif-else: for many choices ◦ (^) Nested if: there are conditional choices inside of any condition Applications
while (Boolean expression): statements
While Loop
(1) by range(start, stop, step) for num in range(10, 1, -2): print("num=", num) (2) loop over a list list_1 = [1, 3, 5, 7, 9] for i in list_1: print(i) (3) loop over a string word = "python" for letter in word: print(letter, end = “ ") # p y t h o n For loop: through a sequence
Nested Loops
A for loop: ◦will “do” something to everything A while loop: ◦ (^) will “do” something until a condition is not true. Exchangeable Comparison: while vs. for
Comparisons
Range