Chapter 1

Chapter 1
Python, IDLE and your first program


In this chapter you are going to:

  • learn about computer programming and the different languages that you can use
  • meet the Python programming language
  • learn how to use IDLE, which will help organise your programs and allow you to run them easily
  • check that your computer has been set up correctly
  • write and run your first program.


Coding

  • Coding is writing instructions for a computer to perform a task. 
    • This code has to be in a form that the computer can understand. 
    • This is more formally known as computer programming.
  • Computers and coding have not been around for a long time but they have sure packed in some interesting history in a short space of time. 
    • The first machine that stored instructions in a way that future computers could take advantage of was the Jacquard loom that used holes punched in cards and was invented in 1801. 
    • Charles Babbage is often credited with inventing the first computer which he described in 1837 but was not built until 100 years later. 
    • In 1989 Guido van Rossum started to create the Python programming language which he named after Monty Python’s Flying Circus, a BBC comedy sketch show.



Programming languages


  • There are many programming languages currently used by coders around the world. 
    • Some are best in one situation, others in another. 
      • HTML is good for producing web pages. 
      • SQL is great at making databases do what you want. 
      • Python is brilliant for writing quick applications, running programming experiments and for building larger applications, including games.


Python

  • Python is a typed computer language. 
    • This makes writing short programs very fast and you can produce almost anything you can imagine.
  • Python is a powerful, modern programming language used by many famous organisations 
    • such as YouTube and NASA. 
    • It is one of three programming languages that can be used to write Google Apps. 
  • Python is a great language. 
  • Enjoy!


IDLE

  • You will start programming in IDLE which comes with Python. 
  • IDLE is a special text editor like Microsoft Word, 
    • except it understands Python and helps you get your code right. 
  • IDLE is itself, a Python application.







Hello World!

  • Since the dawn of programming, when the first cave-coders booted up their cave-computers, it has been a tradition that your first program when learning a new language is ‘Hello World’. 
    • The aim is to try to make the computer say ‘hello’ to the world. 
    • If you can do this you will have tested whether everything that was set up for you is working properly.
Code Box 1.1
print("Hello World!")




Making mistakes

  • Syntax errors are very common when typing in code (as are other errors). 
    • If you make one or two it is not your fault. 
      • It is because although computers are fast, they can also be a bit stupid. 
    • If there are any tiny mistakes in your code, they panic and produce error messages.
      • These messages try to explain to you what the problem is but they are often difficult to understand.
    • Colons, brackets, speech marks, apostrophes and spelling of Python words have to be just right.
      • Although we can read imperfect sentences, computers cannot.



Chapter summary




沒有留言:

張貼留言