Computer Science and an introduction to Pascal

Slides:



Advertisements
Similar presentations
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Advertisements

Programming recap. Do you know these? LOW LEVEL 1 st generation: machine language (110011) 2 nd generation: assembly language (ADD, SUB) HIGH LEVEL 3.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
The If/Else Statement, Boolean Flags, and Menus Page 180
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Introduction to Perl Practical Extraction and Report Language or Pathologically Eclectic Rubbish Lister or …
General Programming Introduction to Computing Science and Programming I.
CS107 Introduction to Computer Science Java Basics.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Introduction to Pascal The Basics of Program writing.
Programming, an introduction to Pascal
1 CS161 Introduction to Computer Science Topic #8.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
GCSE Computing: Programming GCSE Programming Remembering Python.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Component 1.6.
Introduction to Computing Science and Programming I
Whatcha doin'? Aims: To start using Python. To understand loops.
Chapter 2 Basic Computation
Input and Output Upsorn Praphamontripong CS 1110
Lesson 1 - Sequencing.
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Python Let’s get started!.
CMSC201 Computer Science I for Majors Lecture 22 – Binary (and More)
Lesson 1 An Introduction
IF statements.
Variables, Expressions, and IO
Functions CIS 40 – Introduction to Programming in Python
Lesson 1 Learning Objectives
Print slides for students reference
Introduction to the C Language
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Learning to Program in Python
Introduction to the C Language
Learning to Program in Python
PROGRAM STRUCTURE CSC 111.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Fill the screen challenge!
Learning to Program in Python
Introduction to CS Your First C Programs
Introduction to pseudocode
Number and String Operations
Introduction to C++ Programming
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
T. Jumana Abu Shmais – AOU - Riyadh
Computer Science 1 Get out your notebook
Coding Concepts (Basics)
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Introduction In today’s lesson we will look at: why Python?
Welcome to AP Computer Science A!
Primitive Types and Expressions
Introduction to Python
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Computer Science 1 Get out your notebook
Computer Science 1 Get out your notebook
Starter Which of these inventions is: Used most by people in Britain
Python SAT 1 Feedback.
Hardware is… Software is…
Year 8 Computer Science Digital Portfolio
Getting Started With Coding
Presentation transcript:

Computer Science and an introduction to Pascal Introduce self. Find out programming experience of new students plus what they did for GCSE CS (If at all). A Level Computing – Mr Sheehan (MSH)

Logging in (To be completed for helping external students log in) (We are liaising with IT support how to get round this) Ensure everyone can log on.

Virtual Machine: Start -> All programs -> Subject Resources -> ICT -> Programming What is a virtual machine? Why do you think we use a virtual machine for programming in school? Ensure all can open the virtual machine. Mini discussion on virtual machines.

IDE and Programming Language The programming language we will be using in class is Pascal. Most would of you would have used Python for GCSE and so this will give you the experience of another language. The IDE we currently use in lessons is Lazarus version 1.6. This can be downloaded for free here: https://www.lazarus-ide.org/index.php?page=downloads What is an IDE? Let students know they can potentially use other languages for their project. Briefly explain why we use Pascal as many students may consider it an odd choice.

Key words and terms Term Explanation Statement any individual step/instruction in the code Identifier A name for your variables, functions etc. Reserved words Words which are reserved for a specific purpose in the programming language and so can’t be used as an identifier . e.g. IF… WHILE… DO… Subroutines a sub-program, a set of statements written to perform a given task as part of solving the main problem. It can be called by using its identifier. Procedure a subroutine which performs a task but has no return value Function specifically a subroutine which returns a single value and can therefore be used in expressions. Give students a short amount of time to discuss or look up some of these. Ask random pairs for their responses. Give model answers – usually would be added to their programming glossary but this can be done next year. With the person next to you, discuss the definitions of these words in relation to programming.

The Basic Form At its simplest, a Pascal program has the form Identifiers can only contain letters, underscores or numbers and must start with a letter. PROGRAM, BEGIN and END are reserved words. PROGRAM n; BEGIN {statements} END. Where n is a program name Emphasise rules and how reserved words can not be used as an identifier. In Pascal indentations and spacing is not mandatory so explain the importance of good programming practice and how it will help themselves and teacher find problems with their code when it doesn’t work.

Getting Started Lazarus opens automatically when opening the virtual machine. Ensure you have it on screen. Click Start -> New -> Program The first line of the program is called the program heading. The rest of the program is the program body. At least one space or end-of-line must appear between adjacent identifiers, reserved words and numbers. Very briefly explain difference between program and application. (Make sure I also have virtual machine on in the background to use as example if necessary).

First Program: Hello World! To see the effect of a program there must be some output. A single line of output can be produced using the writeln statement. The text to be output must always appear within apostrophes or string quotes. Statements must always end with a semi-colon. Copy this code. Run the program. What is the problem with it? Add readln() under writeln(‘Hello World!’); to fix this. PROGRAM helloworld; BEGIN writeln(‘Hello World!’); END. Students copy code. Should notice that the output flashes up too briefly to read properly before program ends. Introduce readln() – explain it waits for a user input before continuing.

What is wrong with the code? PROGRAM while; BEGIN writeln(‘Hello World!’); END. PROGRAM helloworld; BEGIN writeln(‘Hello World!’) END. PROGRAM helloworld; BEGIN writeln(Hello World!); END. PROGRAM 2_helloworld; BEGIN writeln(‘Hello World!’); END. Will pick random students to identify errors in these code snippets. Open up to whole class if student struggles (Although all have been mentioned early in the lesson)

Try the following Output Examples PROGRAM helloworld; BEGIN writeln(‘Hello’); Writeln(‘World!’); readln(); END. PROGRAM helloworld; BEGIN writeln(‘Hello’, ’World!’); readln(); END. PROGRAM helloworld; BEGIN writeln(‘Hello’); writeln(); writeln(‘World!’); readln(); END. PROGRAM helloworld; BEGIN write(‘Hello’); writeln(‘World!’); readln(); END. Ask class for each one before revealing answers. Ask class difference between write and writeln at the end.

Output Spaces and end-of-line make no difference to the compiler. To the human reader, however, their inclusion is very important; neat layout is a major contributory factor towards program transparency. Comments are helpful to identify what is happening in a particular part of the program, not only for you but anyone else who reads the code. PROGRAM helloworld; BEGIN //Prints “Hello World! To the screen {Prints “Hello World! To the screen} writeln(‘Hello World!’); END. Tell class I want comments as //Enter comments. Explain they will be important with more complicated code and within projects. Comments

Exercises Print your name to the screen. Print your name to the screen in a border made of a character of your choice. Write a program to draw a rocket. Write a program to print your initials in large letters. * *** ***** ******* ** ** Give students time to complete these. Extension is on the next page.

Extension The following code has 3 integers (whole numbers) set up to be used in the program. Currently the program asks the user for a number and stores it in the variable Num1 Complete the program so the user must enter 2 numbers. Then have the sum of those two numbers printed to the console. Extension introduces variables. Although not taught they should be able to figure it out with the code given – can use internet if necessary,.