Advanced Computer Programming Sinan AYDIN Anadolu niversitesi Syllabus

Advanced Computer Programming Sinan AYDIN Anadolu Üniversitesi

Syllabus Week Content 1. Week: 2. Week: 3. Week: 4. Week: 5. Week: 6. Week: 7. Week: 8. Week: 9. Week: 10. Week: 11. Week: 12. Week: 13. Week: 14. Week: Review of the basic concepts: Flow diagrams, Control structures, Cycles Review of the basic concepts : Functions, Modules, File I/O, Exception handling Review of the basic concepts: Tuples, Lists, Dictionaries Stack Implementation; Multidimensional lists Classes and Data Abstractions Midterm I Inheritance Polymorphism Sort algorithms Search algorithms Midterm II Num. Py module Sci. Py module Project presentation Advanced Computer Programming

Resources Advanced Computer Programming

Review of the Basic Concepts Computer Programming Phyton Control Structures Cycles Flow Diagrams Review

Computer Programming Functions, Scoping, Abstraction Programmers write instructions in various programming languages, some directly understandable by computers and others that require intermediate translation steps. Although hundreds of computer languages are in use today, the diverse offerings can be divided into three general types: 1. Machine languages 2. Assembly languages 3. High-level languages

Displaying Text Introduction to Python Programming

Displaying Text Introduction to Python Programming

Adding Integers Introduction to Python Programming Variable names such as integer 1, integer 2 and sum actually correspond to Python objects. Every object has a type, a size, a value and a location in the computer’s memory. A program cannot change an object’s type or location.

Adding Integers Introduction to Python Programming

Arithmetic Operators Introduction to Python Programming

Arithmetic Operators Introduction to Python Programming

Equality and relational operators. Introduction to Python Programming

Equality and relational operators Introduction to Python Programming

Control Structures Introduction to Python Programming

If Selection Structre Introduction to Python Programming

If Selection Structre Introduction to Python Programming

If Selection Structre Introduction to Python Programming

while Repetition Structure Introduction to Python Programming

Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) Introduction to Python Programming A class of ten students took a quiz. The grades (integers in the range 0 – 100) for this quiz are available. Determine the class average on the quiz. Pseudocode algorithm that uses counter-controlled repetition to solve the class-average problem. Set total to zero Set grade counter to one While grade counter is less than or equal to ten Input the next grade Add the grade into the total Add one to the grade counter Set the class average to the total divided by ten Print the class average

Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) Introduction to Python Programming A class of ten students took a quiz. The grades (integers in the range 0 – 100) for this quiz are available. Determine the class average on the quiz. Pseudocode algorithm that uses counter-controlled repetition to solve the class-average problem. Set total to zero Set grade counter to one While grade counter is less than or equal to ten Input the next grade Add the grade into the total Add one to the grade counter Set the class average to the total divided by ten Print the class average total=0 grade. Counter=1 while grade. Counter<=10: grade=input("Enter grade: ") grade=int(grade) total=total+grade. Counter=grade. Counter+1 average=total/10 print("class average is", average)

Formulating Algorithms: Case Study 2 (Counter-Controlled Repetition) Introduction to Python Programming A class of ten students took a quiz. The grades (integers in the range 0 – 100) for this quiz are available. Determine the class average on the quiz. Pseudocode algorithm that uses counter-controlled repetition to solve the class-average problem. Initialize total to zero Initialize counter to zero Input the first grade (possibly the sentinel) While the user has not as yet entered the sentinel Add this grade into the running total Add one to the grade counter Input the next grade (possibly the sentinel) If the counter is not equal to zero Set the average to the total divided by the counter Print the average else Print “No grades were entered”

Formulating Algorithms: Case Study 2 (Counter-Controlled Repetition) Introduction to Python Programming A class of ten students took a quiz. The grades (integers in the range 0 – 100) for this quiz are available. Determine the class average on the quiz. Pseudocode algorithm that uses counter-controlled repetition to solve the class-average problem. Initialize total to zero Initialize counter to zero Input the first grade (possibly the sentinel) While the user has not as yet entered the sentinel Add this grade into the running total Add one to the grade counter Input the next grade (possibly the sentinel) If the counter is not equal to zero Set the average to the total divided by the counter Print the average else Print “No grades were entered”

Augmented Assignment Symbols Python provides several augmented assignment symbols for abbreviating assignment expressions. c = c + 3 can be abbreviated with the augmented addition assignment symbol += as c += 3 variable = variable operator expression -- > variable operator= expression where operator is a binary operator, such as +, -, **, *, /, or %, can be written in the form Introduction to Python Programming

Introduction to Python Programming For Repetition Structure for counter in range( 1, 101 ): for counter in range( 100, 0, – 1 ): for counter in range( 7, 78, 7 ) for counter in range( 99, -11 ):

For Repetition Structure A person invests $1000 in a savings account yielding 5 percent interest. Assuming that all interest is left on deposit in the account, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula for determining these amounts: a=p(1+r)n where p is the original amount invested (i. e. , the principal), r is the annual interest rate, n is the number of years and a is the amount on deposit at the end of the nth year. Introduction to Python Programming

For Repetition Structure A person invests $1000 in a savings account yielding 5 percent interest. Assuming that all interest is left on deposit in the account, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula for determining these amounts: a=p(1+r)n where p is the original amount invested (i. e. , the principal), r is the annual interest rate, n is the number of years and a is the amount on deposit at the end of the nth year. Introduction to Python Programming

Break and continue Statements Introduction to Python Programming

Break and continue Statements Introduction to Python Programming

Logical Operators Introduction to Python Programming

Structure Programming Introduction to Python Programming

Structure Programming Introduction to Python Programming Rules for Forming Structured Programs 1) Begin with the so called simplest flowchart (Fig. 3. 34). 2) Any rectangle (action) can be replaced by two rectangles (actions) in sequence. 3) Any rectangle (action) can be replaced by any control structure (sequence, if/else, while or for). 4) Rules 2 and 3 can be applied as often as you like and in any order.
- Slides: 31