Programming for GCSE 1.2 Writing Python Scripts
This guide provides an introduction to writing Python scripts suitable for GCSE Computing. You'll learn about creating Python programs, including how to structure files, utilize comments for clarity, and the importance of layout with proper indentation. The 'print' function will be discussed extensively, showcasing its capability to output strings and numbers. By the end, you'll have a solid foundation in creating simple yet effective Python scripts, making programming more accessible than ever.
Programming for GCSE 1.2 Writing Python Scripts
E N D
Presentation Transcript
TeachingLondon Computing Programming for GCSE1.2 Writing Python Scripts William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London
Aims • Writing Python program • Creating files • Comments • Layout • Using ‘print’
Python Program • Python programs can be very simple • File (best to name it with extension .py) • Much simpler than Java (or C♯) print(”hello”)
Comments • Comment explain a program • Comments can be used to help plan a program # Thisprogram prints a greeting print(”hello”)
Layout • An important feature of Python • Indentation matters! Always start in the same column
The ‘print’ function • The ‘print’ function is used to output a string • In these examples • The print function has two strings or an expression • Note the spaces • Both statements output the same thing print(“hello“, “world“) print(“hello“ + “ hello“)
Printing Numbers • Print can also output a number • Example >>> print("Average is", (30 + 40)/2) Average is 35.0
Summary • A Python program is a file containing statements • Simple! • ‘print’ for output • String and numbers