1 / 21

Problem Solving Warm-Up

Problem Solving Warm-Up. Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): 8 8 8 = 6. How to Problem Solve. https:// www.youtube.com/watch?v=zrzMhU_4m-g The single most important skill for a computer scientist!!!!!!.

richardw
Download Presentation

Problem Solving Warm-Up

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. Problem Solving Warm-Up Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): 8 8 8 = 6

  2. How to Problem Solve • https://www.youtube.com/watch?v=zrzMhU_4m-g • The single most important skill for a computer scientist!!!!!!

  3. Think like a computer programmer! • This way of thinking combines some of the best features of mathematics, engineering, and natural science. Like mathematicians, computer scientists use formal languages to denote ideas (specifically computations). Like engineers, they design things, assembling components into systems and evaluating tradeoffs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.

  4. Think Python! • The programming language you will learn is Python. • Python is an example of a high-level language; other high-level languages you might have heard of are C, C++, Perl, and Java.

  5. PythonChapter 1 – Getting Started What is Python and why do we use it? • Python is an easy to use programming language: you can use it to create web apps, games, and even a search engine. • Developed by Guido van Rossum and released in 1991 • Python got it’s name from the movie Monty Python • Python is easy to use • Bridges the gap between programmers brain and the computer • Clear and simple rules make the language very close to English • Straightforward language – it has been called “programming at the speed of thought” • Programs are shorter and take less time to create

  6. Python is powerful • Used by companies such as Google, IBM, Microsoft, Verizon, Electronic Arts (EA Sports), Disney Interactive • Python is a “glue” language • Python runs everywhere • Can be integrated into other languages Java, C++, etc. • Python is free! • Can install on any computer and not pay a penny!

  7. Some Important Terminology Functions – like a mini program that goes off and performs a task. • You kick off or call a function by using the function name, followed by a set of parenthesis. • You can give or pass a function values to work with. • These values, called arguments are put inside the parenthesis. Ex. Print (“Game Over”) displays Game Over argument function *Note: Python functions are case sensitive – Print works, PRINT won’t

  8. String – series of characters • A string can contain letters, numbers, and symbols. Ex: hello, 123abc, i love school Statement – a complete instruction Ex: print(“Game Over”) • In English, a statement is a complete thought, in Python it is a complete instruction. It does something. Programs are made up of a number of statements Code – programming statements

  9. Color Coding • Python uses color coding, called syntax highlighting , to help you understand what you have typed. • Function Purple • Strings Green • Output Blue

  10. Introducing IDLE Python comes with an integrated development environment called IDLE. A development environment is a set of tools that makes writing programs easier. You can think of it as a word processor for your programs. IDLE provides two modes in which to work: an interactive mode and a script mode. Programming in Interactive Mode Time to write your first program! In this mode, you can tell Python what to do and it will respond immediately. Start up your Python Programs!

  11. To begin: Start Menu > All Programs > Python 3.1 > IDLE (Python GUI) You should see a screen similar to this: This window is called the python shell These three arrows are a command prompt – ready for you to give instructions

  12. At the command prompt type print(“Game Over”) and then press the Enter Key

  13. TA-DA!You’ve just written your first Python program

  14. Function • The print() function can display text, surrounded by quotes, that you put inside the parenthesis. If you put nothing it will print a blank line. String called string literal, because it is literally the sequence of characters that make up that word Output

  15. Generating an Error • Computers take everything literally, if you misspell a function it will have no idea what you mean. Try typing: primt(“Game Over”)

  16. Programming in Script Mode • Interactive mode gives you immediate feedback, but you can’t save programs and run them later. • In script mode you can write, edit, load, and save your programs. • Like a word processor for your code, you can even find and replace, and cut and paste.

  17. Write your first program (again) • Type print(“Game Over”) and press Enter • Nothing happens! This is because you are writing a list of statements to be executed later. • Once you save your program, you can run it.

  18. To save your program, select File > Save as.*For now just save it to your desktop • Give the program the name game_over.py *Make sure you save all programs with the .py extension. This allows various applications including IDLE to recognize these files as Python programs. • To run, select Run > Run Module • Notice your interactive window still contains old text from before • Try running the program from your desktop – double click it. • What happens?

  19. We need to add a line to the end of all of our programs so that the program won’t close until the user hits enter. This line is input(“\n\nPress the enter key to exit.”) Now once the user presses the Enter key, the program exits and the console window will disappear. *Note: The computer ignores blank lines. These are just for humans reading code. Blank lines make programs easier to read, so use them when you write. Keep related code together and separate sections with a blank line

  20. And finally, Using Comments • Can be written at any part in a program • Color code red • Computer ignores them – they are meant for humans • Help you remember the goal of your program and VERY useful to other programmers. • Create using a number sign symbol. • Ex: # Game Over # Demonstrates the print functions

  21. Anything after this symbol (except in a string) on the rest of the line is a comment. • You should start all of your programs with a few comments – it is helpful to list the title and purpose of the program. You should also list the name of the programmer and the date the program was written. • Go back and add these comments to the beginning of your program End of Chapter 1!

More Related