VJC Chapter 2 Data Types
Uploaded by cheesemuffin · 10 December 2025
Preview
2022/VJC/JC1/H2Computing/9569 Chapter 2: Data Types and Operators Contents 1 Data Types 1.1 Type conversion 1.2 Input 1.3 Output 2 Numbers 2.1 Integer in different bases 2.2 Arithmetic Operators 3 Boolean 3.1 Boolean operators 3.2 Logical operators 4 Strings 4.1 ASCII code and Unicode 4.2 Create Strings 4.3 Escape character 4.4 Indexing 4.5 Slicing 4.6 Immutable 4.7 String operators 4.8 Built-in String methods Syllabus Learning Outcomes 2.2 Programming Elements and Constructs Use programming language elements and constructs to write recursive and non-recursive programs to solve a variety of problems. 2.2.1 Understand the different types: integer, real, char, string and Boolean and initialise arrays (1- dimensional and 2-dimensional). 2.2.2 Use common library functions for input/output, strings and mathematical operations. 3.1 Data Representation Understand that values can be represented in different number bases: denary, binary and hexadecimal. 3.1.1 Represent data in binary and hexadecimal forms. 3.1.2 Write programs to perform the conversion of positive integers between different number bases: denary, binary and hexadecimal forms; and display results. 3.2 Character Encoding Understand the use of ASCII code and Unicode to represent characters. 3.2.1 Give examples of where or how Unicode is used. 3.2.2 Use ASCII code in programs. 1
2022/VJC/JC1/H2Computing/9569 1 Data Types Multiple data types are developed for convenient data manipulation and management. In the table below are some of the more common data types: The data type is set when you assign a value to a variable. The type() function can be used to check the data type of a variable. 1.1 Type conversion We can convert one type of number into another. Operations like addition, subtraction can convert integer to float implicitly (automatically), if one of the operands is float. We can also use built-in functions like int() , float() and str() to convert between types explicitly. 2 Data Types Description Example Integer A signed whole number 1, 1234, -15 Float (real) A signed number with a decimal point 1.0, 2.345, - 54.321 Boolean The logical values TRUE and FALSE TRUE, FALSE String A sequence of zero or more characters ‘hello’, ‘action 123’, ‘A-level’, ‘’
2022/VJC/JC1/H2Computing/9569 1.2 Input We can ask user for input using Python built-in input() function. ● When input() function is called, the program will stop and wait for user to key in data. ● It is optional to add prompt as fun
Content continues in the PDF.
Related notes
- VJC Chapter 21 SQLite with PythonNotes/Practices · 2025
- VJC Chapter 23 Web Applications PrinciplesNotes/Practices · 2025
- VJC Chapter 10 RecursionNotes/Practices · 2025
- VJC Chapter 20 SQLNotes/Practices · 2025
- VJC Chapter 16 Hash TableNotes/Practices · 2025
- VJC Chapter 22 NoSQLNotes/Practices · 2025

