Overview of Programming Programs and Software Development Life Cycle

introduction to programming n.w
1 / 9
Embed
Share

"Learn about the fundamentals of programming, including problem analysis, algorithm development, and program testing. Explore the Software Development Life Cycle (SDLC) and follow an example program in Python to convert miles to kilometers."

  • Programming Fundamentals
  • Software Development
  • Programming Languages
  • Python Programming

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Introduction to Programming Programs are written to address specific problems Ex: compute taxes, loan payments, BMI index, etc. Steps in program development problem analysis, algorithm and program development, testing and refinement SDLC (Software Development Life Cycle) Professor John Carelli Kutztown University Computer Science Department

  2. Software Development Life Cycle Identify/state the problem Specify the requirements Analyze the problem develop a strategy to address it Design an algorithm to solve the problem What is an Algorithm? Implement the algorithm Write the computer program! Test and verify the completed program Maintain and update the program Professor John Carelli Kutztown University Computer Science Department

  3. First Example Develop a program to convert miles to kilometers 1. Create a program plan (following the SDLC) Example: milesPlan.txt 2. Write the program in an appropriate programming language Example: miles.py Professor John Carelli Kutztown University Computer Science Department

  4. Overview of a Python Program # # miles.py # - converts distance in miles to kilometers. # miles.py this example illustrates some common elements in a Python program Comments Statements Assignments Expressions Functions # conversion factor (kilometers in a mile) KM_PER_MILE= 1.609 # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

  5. Comments # # miles.py # - converts distance in miles to kilometers. # # symbol indicates a comment Everything from the # to the end of the line is ignored Used to describe the code in English or provide other non-code information # conversion factor KM_PER_MILE= 1.609 # km in a mile # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

  6. Statements # # miles.py # - converts distance in miles to kilometers. # A statement is the actual Python code that does something Statements can contain: Assignments Store information Using variables and = Expressions Evaluate something calls to functions # conversion factor (kilometers in a mile) KM_PER_MILE= 1.609 # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

  7. Assignments # # miles.py # - converts distance in miles to kilometers. # Assignments are statements in which information is stored for future retrieval and use Information is stored using a named memory location called a variable KM_PER_MILE, miles, kms The variable is assigned its value using the variable name and = (also called the assignment operator) # conversion factor (kilometers in a mile) KM_PER_MILE= 1.609 # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

  8. Expressions # # miles.py # - converts distance in miles to kilometers. # Expressions are portions of a statement in which a calculation or evaluation of some sort is performed For example, a mathematical calculation # conversion factor (kilometers in a mile) KM_PER_MILE= 1.609 # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

  9. Function calls # # miles.py # - converts distance in miles to kilometers. # A function contains pre-written code that can be re-used in programs to perform specific tasks To use a function, it must be called or invoked by name Information is passed to the function within the required parenthesis. # conversion factor (kilometers in a mile) KM_PER_MILE= 1.609 # get the distance in miles miles= input("Enter the distance in miles: ") # calculate the kilometers # note: convert the miles string to a number kms= KM_PER_MILE * float(miles) In miles.py input() : gets information from the user print() : displays results to the screen float() : type conversion (more later ) # output the results print("The distance in miles is:",miles) print("The distance in kilometers is:",kms) Professor John Carelli Kutztown University Computer Science Department

More Related Content