CGP GCSE COMPUTING - SECTION FIVE - PROGRAMMING BASICS - DATA TYPES

Ace your homework & exams now with Quizwiz!

The characters in a string are usually numbers starting with what digit

0

Can Constants and variables values be changed? Explain

A constant is Assigned a data value at design time which can't be changed. A variable can change value which makes it far more useful

PAGE 44 STRINGS What are strings

A datatype made up of characters these characters are alpha numeric

What is the name of the constant or variable linked to

A memory location that stores the data value

What common maths rule do computers follow when calculating

BODMAS

Languages have functions that let you manually convert between data types what is this process called

Casting

Strings can be joined together to form new strings what is this process called and how is it often done

Concatenation Often done using the addition operator

PAGE 43 CONSTANTS AND VARIABLES data valuesCan be stored as two things what are they

Constants Or variables

Some programming languages give odd results using division integers what function can you use to avoid this

DIV and MOD

What are strings usually written inside

Double quotation marks But sometimes single quotation marks are used

Give the appropriate data type for each of the categories shown in this registration form Initial of first name. N Surname. Chapman Age In whole years. 27 Height in metres. 1.64 Male or female. Female

Initial of first name. Stored as a character Surname. As a string. Age In whole years. As an integer Height in metres. As a real data type Male or female. As Boolean

Page 41 PROGRAMMING BASICS - DATA TYPES What are the five main data types Give their pseudocode Describe their characteristics Give examples

Integer INT Whole numbers only 0, 6, 10293. Real or float. REAL. Numbers that have one decimal place. 0.15, -5.87 Boolean. BOOL. Can only take 1 to 2 values usually true or false. true/false. 1/0 Character. CHAR. A single letter, number or symbol. A, k. 5. + String. STRING. Used to represent text it is a collection of characters. FsTmQ2. £money£

What do each of these commands convert

Intl( "1"). String 1 into integer 1 Float ( 1). Integer 1 into float 1.0. Bool ( 1) Integer. 1 to Boolean value True Str ( True). Boolean value True to string "True"

How can the casting be done using what commands

Intl( ). Float ( ). Bool ( ) Str ( )

What is the assignment operator used for

It Is used to assign values to Constants or variables

Why is it important to use the correct data type

It makes code more memory efficient robust (meaning hard to break) and predictable

Are these '1's the same?

No they're all different

Look at the table on page 42 and check you understand all the signs

Page 42

Look at the example on page 43 and work through it

Page 43 What are strings

Look at the example on page 44 and work it out

Page 44

How can you declare the Constants and variables you are going to use

Pressure declared as a constant with integer type Constants are assigned values when they declared Temperature and weight declared as variables with real type Initial values can be assigned to variables but they don't have to be

What is the exponentiation operator used to do

Raise a number to a power

What is the DIV and MOD operators used to do

Return the whole number part of a division then the M OD operator will give the remainder

What does the size of the memory location dependent upon

The data type

What happens if you try to change the value of a constant in the program

The interpreter or compiler will return an error

PAGE 42 PROGRAMMING BASICS - OPERATORS What are operators

They are special characters that perform certain functions

What do you comparison operators do

They compare the expression on the left hand side to the expression on the right hand side and produce a Boolean value which is either true or false

Before you can use a constant or variable what often has to be done at the start of the program

They have to be declared before you can use them

What do you basic arithmetic operators do

They take two values and perform a maths function on then the addition subtraction multiplication and division operators do what you expect

How can you find the ASCII number of characters and vice versa

Use the ASC ( ). And. CHR ( ) functions ASC ("b") converts the character "b" into its ASC number 98 CHR (98) converts the ASCII number 98 into its equivalent character "b"

Describe casting. Including the commands that are used

Using language functions to Manually convert Between data types int ( ) float ( ) bool ( ) str( ) Commands

Programming languages can be weakly typed or strongly typed What does this mean

Weakly typed = Will try to convert datatypes To avoid areas however this can lead to unpredictable results Strongly typed languages want to try to convert datatypes I will produce more errors but more predictable results

REVISION QUESTIONS FOR SECTION FIVE Datatypes, operators, Constants, variables and strings Pages 41 to 44 Define the following datatypes Integer Real Boolean Character String

integer = Real = Boolean = Character = String =

When writing constants and variables on which side of the = should they be What side should what you are assigning be

left for constants and variables Right for assigning

Following are some common string manipulation functions that you need to know say what operation and effect on X goes with the typical function x.upper x.lower x.length x[i] x.subString(a,b)

x.upper - Changes all characters in string x to uppercase - HELLO x.lower - Changes or characters in string to Lowercase - hello x.length - Returns the number of characters in string x - 5 x[i] - Extract the character in position i from string x - x[1] = "e" x.subString(a,b) - Extracts a string starting at position a with a length b from string x - x.subString(3,2) = "lo"


Related study sets

CLEP - Introductory Sociology Statistics Section

View Set

Area and circumference word problems

View Set

ATI Scope and Standards of Practice

View Set

Taxes, retirement and other insurance concepts quiz

View Set

Small Group Comm (McGuire) Test #1 Review

View Set

Analogies and Homologies, ancestral or derived?

View Set

Chapter 4: Taxes, retirement, and other insurance concepts

View Set