1 / 31

Sinan AYDIN Anadolu Üniversitesi

Advanced Computer Programming. Sinan AYDIN Anadolu Üniversitesi. Syllabus. Advanced Computer Programming. Resources. Advanced Computer Programming. Review of the B asic C oncepts. Review. Computer Programming Phyton Control S tructures Cycles Flow D iagrams.

smoser
Télécharger la présentation

Sinan AYDIN Anadolu Üniversitesi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Computer Programming Sinan AYDINAnadolu Üniversitesi

  2. Syllabus Advanced Computer Programming

  3. Resources Advanced Computer Programming

  4. Review of the BasicConcepts Review Computer Programming Phyton Control Structures Cycles Flow Diagrams

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

  6. IntroductiontoPython Programming DisplayingText

  7. IntroductiontoPython Programming DisplayingText

  8. IntroductiontoPython Programming AddingIntegers Variablenamessuch as integer1, integer2 andsumactuallycorrespondtoPythonobjects. Everyobject has a type, a size, a valueand a location in thecomputer’smemory. A program cannotchange an object’stypeorlocation.

  9. IntroductiontoPython Programming AddingIntegers

  10. IntroductiontoPython Programming ArithmeticOperators

  11. IntroductiontoPython Programming ArithmeticOperators

  12. IntroductiontoPython Programming Equalityandrelationaloperators.

  13. IntroductiontoPython Programming Equalityandrelationaloperators

  14. IntroductiontoPython Programming Control Structures

  15. IntroductiontoPython Programming IfSelectionStructre

  16. IntroductiontoPython Programming IfSelectionStructre

  17. IntroductiontoPython Programming IfSelectionStructre

  18. IntroductiontoPython Programming whileRepetitionStructure

  19. IntroductiontoPython Programming Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) A class of ten studentstook a quiz. Thegrades (integers in therange 0 –100) forthisquiz areavailable. Determinetheclassaverage on thequiz. 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

  20. IntroductiontoPython Programming Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) A class of ten studentstook a quiz. Thegrades (integers in therange 0 –100) forthisquiz areavailable. Determinetheclassaverage on thequiz. 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=0gradeCounter=1whilegradeCounter<=10:grade=input("Entergrade:")grade=int(grade) total=total+gradegradeCounter=gradeCounter+1average=total/10print("classaverage is", average)

  21. IntroductiontoPython Programming Formulating Algorithms: Case Study 2(Counter-Controlled Repetition) A class of ten studentstook a quiz. Thegrades (integers in therange 0 –100) forthisquiz areavailable. Determinetheclassaverage on thequiz. 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”

  22. IntroductiontoPython Programming Formulating Algorithms: Case Study 2(Counter-Controlled Repetition) A class of ten studentstook a quiz. Thegrades (integers in therange 0 –100) forthisquiz areavailable. Determinetheclassaverage on thequiz. 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”

  23. IntroductiontoPython Programming Augmented Assignment Symbols Python provides several augmented assignment symbols for abbreviating assignment expressions. c = c + 3can 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

  24. IntroductiontoPython Programming ForRepetitionStructure forcounter in range( 1, 101 ): forcounter in range( 100, 0, –1 ): forcounter in range( 7, 78, 7 ) forcounter in range( 99, -1, -11 ):

  25. IntroductiontoPython Programming ForRepetitionStructure 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.

  26. IntroductiontoPython Programming ForRepetitionStructure 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.

  27. IntroductiontoPython Programming Break andcontinueStatements

  28. IntroductiontoPython Programming Break andcontinueStatements

  29. IntroductiontoPython Programming LogicalOperators

  30. IntroductiontoPython Programming Structure Programming

  31. IntroductiontoPython Programming Structure Programming Rules forFormingStructured Programs 1) Beginwiththesocalledsimplestflowchart (Fig. 3.34). 2) Anyrectangle (action) can be replacedbytworectangles (actions) in sequence. 3) Any rectangle (action) can be replaced by any control structure (sequence, if, if/else, if/elif/else, while or for). 4) Rules 2 and 3 can be applied as often as you like and in any order.

More Related