Difference between revisions of "EGR 103/Concept List/F23"

From PrattWiki
Jump to navigation Jump to search
(Lecture 2 - 9/1 - Introduction to Programming)
(Lecture 2 - 9/1 - Introduction to Programming)
Line 18: Line 18:
 
** See if number is evenly divisible by any integer between 2 and the square root of the number - but how do we ask the ''computer'' to do that?
 
** See if number is evenly divisible by any integer between 2 and the square root of the number - but how do we ask the ''computer'' to do that?
 
** We can use output to get the computer to ask for a number and we can use input to allow the computer to receive that number
 
** We can use output to get the computer to ask for a number and we can use input to allow the computer to receive that number
We can use math and the mod operator (%) to see if one number is evenly divisible by another, a loop to go through all possible relevant divisors, and a decision structure to choose what to do if we determine that a number is not prime.   
+
**We can use math and the mod operator (%) to see if one number is evenly divisible by another, a loop to go through all possible relevant divisors, and a decision structure to choose what to do if we determine that a number is not prime.   
 
* Very quick tour of Python with Spyder
 
* Very quick tour of Python with Spyder
 
** Console (with history tab), info box (with variable explorer, files, and other tabs), and editing window
 
** Console (with history tab), info box (with variable explorer, files, and other tabs), and editing window

Revision as of 02:14, 2 September 2023

Lecture 1 - 8/28 - Course Introduction

Lecture 2 - 9/1 - Introduction to Programming

  • Seven steps of programming The Seven Steps Poster
  • Almost all languages have input, output, math, conditional execution (decisions), and repetition (loops)
  • Problem: Consider how to decide if a number is a prime number
    • Some "shortcuts" for specific factors (2, 3, and 5, for example) but need to have a generalized approach
    • See if number is evenly divisible by any integer between 2 and the square root of the number - but how do we ask the computer to do that?
    • We can use output to get the computer to ask for a number and we can use input to allow the computer to receive that number
    • We can use math and the mod operator (%) to see if one number is evenly divisible by another, a loop to go through all possible relevant divisors, and a decision structure to choose what to do if we determine that a number is not prime.
  • Very quick tour of Python with Spyder
    • Console (with history tab), info box (with variable explorer, files, and other tabs), and editing window
    • Pushing "play" button or hitting F5 will save the script, change the working directory, and run the script
    • Quick introduction to variable types: int, float, str
    • Quick introduction to indexing: Python is "0" indexed, meaning if there is a collection of items called x, x[0] will be the "first" item in the collection and x[N-1] where N is the total number of items will be the last item. Also, reverse indexing, where x[-1] is the last item and x[-N] is the first item.