\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{{[}deleted{]}} \pdfinfo{ /Title (programming-aqa-computer-science.pdf) /Creator (Cheatography) /Author ({[}deleted{]}) /Subject (Programming - AQA Computer Science Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0FE300} \definecolor{LightBackground}{HTML}{F0FDEF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Programming - AQA Computer Science Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{{[}deleted{]}} via \textcolor{DarkBackground}{\uline{cheatography.com/56036/cs/15020/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}{[}deleted{]} \\ \uline{cheatography.com/deleted-56036} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 8th May, 2018.\\ Updated 8th May, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Structured Programming}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{The {\bf{structured approach to programming}} means that code is more logical and readable, making it easier to debug and maintain. It also makes it more efficient. The most important part of this approach is {\bf{modularised programming}}, which is the use of subroutines. Other components include detailed {\bf{code annotation}} and clearly named variables.% Row Count 7 (+ 7) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.128 cm} x{3.952 cm} x{1.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Data Types}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Data Type}} & {\bf{Definition}} & {\bf{Example(s)}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Integer}} & A whole, positive number. & 134 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Real}} or {\bf{Float}} & Any number, including decimals and negatives. & -19.21 \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} {\bf{Character}} & A letter, number, space, etc. that can be typed, in accordance with ASCII or Unicode. & @ \tn % Row Count 12 (+ 5) % Row 4 \SetRowColor{LightBackground} {\bf{String}} & A string of characters. & "Hello, world!" \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} {\bf{Boolean}} & Logical values based on binary (1 and 0). & True, False \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{{\bf{Data Type}}: A specific type of value (and variable) that must be handled in a certain way.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Relational Operators}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Symbol}} & {\bf{Meaning}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} = & equal to \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} ≠ & not equal to \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \textless{} & less than \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \textgreater{} & greater than \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} ≤ & less than or equal to \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} ≥ & greater than or equal to \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Maths (in Python)}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operation}} & {\bf{Example}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} Addition & {\bf{Pseudocode}}: 11 + 2 = 13 \{\{nl\}\} {\bf{Python example}}: `11 + 2 = 13` \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} Subtraction & {\bf{Pseudocode}}: 11 - 2 = 9 \{\{nl\}\} {\bf{Python example}}: `11 - 2 = 9` \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{Multiplication} & {\bf{Pseudocode}}: 11 x 2 = 22 \{\{nl\}\} {\bf{Python example}}: `11 * 2 = 22` \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} Real or Float Division & {\bf{Pseudocode}}: 11 DIV 2 = 5.5 \{\{nl\}\} {\bf{Python example}}: `11 / 2 = 5.5` \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} Integer Division & {\bf{Pseudocode}}: 11 // 2 = 5 \{\{nl\}\} {\bf{Python example}}: `11 // 2 = 5` \tn % Row Count 16 (+ 3) % Row 6 \SetRowColor{LightBackground} Remainder of a Division & {\bf{Pseudocode}}: 11 MOD 2 = 1 \{\{nl\}\} {\bf{Python example}}: `11 \% 2 = 1` \tn % Row Count 19 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Selection}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Selection}} is when a program makes a decision, usually taking the form of IF statement. \newline % Row Count 2 (+ 2) For example (pseudocode): \newline % Row Count 3 (+ 1) `IF x = TRUE THEN` \newline % Row Count 4 (+ 1) `~PRINT "Yes."` \newline % Row Count 5 (+ 1) `ELSE` \newline % Row Count 6 (+ 1) `~PRINT "No."`% Row Count 7 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Variables}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is the 'scope' of a variable?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}The part of the program where a variable is valid and accessible.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Why is it important to give variables distinctive identifiers?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}This makes debugging and maintenance easier, as it is easier for the programmer to understand the purpose of the variable.} \tn % Row Count 8 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Robust \& Secure Programming}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{There are two main ways to make programs more robust. \newline % Row Count 2 (+ 2) Firstly, using {\bf{data validation}}, which is most easily done using an IF/ELIF/ELSE statement or a TRY/EXCEPT statement. This makes sure the data inputted by the user is valid, preventing a runtime error. \newline % Row Count 7 (+ 5) Secondly, {\bf{authentication}}. This primarily takes the form of passwords. \newline % Row Count 9 (+ 2) However, {\bf{testing}} is also key in ensuring that a program is robust. A programmer must test typical (normal), boundary (extreme), and erroneous data to guarantee that the program deals with data correctly.% Row Count 14 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Data Structures}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What are {\bf{data structures}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A data structure is a way of storing data.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{What is an {\bf{array}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}An array is a collection of related data (of the same data type). Each piece of data is an {\bf{element}} with a specific {\bf{index}}. They may also be called 'lists'.} \tn % Row Count 7 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is a {\bf{two dimensional array}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Essentially, a 2D array is just an array made of arrays. They can be thought of as a matrix. Possible uses include a bitmap for an image.} \tn % Row Count 11 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{What is a {\bf{record}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A record is very similar to an array, except multiple data types can be stored together.} \tn % Row Count 14 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Programming Languages}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{High-Level Languages vs Low-Level Languages} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Most programs are initially written in high-level programming languages (e.g. Python) because these are more like human languages, meaning that they are easier for programmers to understand, code in, and debug. They are said to provide a 'higher level of abstraction' from machine code. Low-level langages are very different and much more difficult. Despite this, programming in machine code allows for the optimisation of code and avoid code having to be translated.} \tn % Row Count 11 (+ 11) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Machine Code vs Assembly Language} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Both machine code and assembly language are low-level languages, with assembly code having a 1:1 correspondance with machine code. However, each type of processor has its own specific machine code instruction set, which is expressed in binary. Assembly language is generally used for software for embedded systems and for controlling specific hardware components.} \tn % Row Count 20 (+ 9) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Translation} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}All programs written in high-level languages or assembly language must be translated into machine code before they can be run.} \tn % Row Count 24 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Interpretors, compilers, and assemblers} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}An {\bf{assembler}} translates assembly language to machine code. An {\bf{interpretator}} translates high-level languages into machine code. It does so {\bf{line-by-line}}, which makes debugging easier. A {\bf{compiler}} also translates high-level languages to machine code, but it {\bf{translates the whle program before running}}. While the compliation process is slow, the machine code can then be stored and run quickly in future.} \tn % Row Count 34 (+ 10) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Types of Iteration}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is {\bf{definite iteration}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}There is a set number of iterations.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Example of definite iteration (Python):} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`for i in range(5): \{\{nl\}\} ~ x = x + 1`} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is {\bf{indefinite iteration}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}There is not set number of iterations, as it is instead dependent on when a certain condition becomes true.} \tn % Row Count 8 (+ 4) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Example of indefinite iteration (Python):} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`while x \textless{} 5: \{\{nl\}\} ~ x = x + 1`} \tn % Row Count 10 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is {\bf{nested iteration}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A loop (iteration) within a loop.} \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Examples of nested iteration (Python):} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}`while n == False: \{\{nl\}\} ~ for i in range(5): \{\{nl\}\} ~ ~ x = x + 1`} \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Note that selection statements can also be nested.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Boolean Logic Gates}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{8.4cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/danielles_1525229795_logic gates.PNG}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{SOURCE: \seqsplit{www.cs.hmc.edu/csforall/ComputerOrganization/ComputerOrganization.html}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Subroutines}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{What is are {\bf{subroutines}}?} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Named 'out of line' blocks of code that are executed (called) by writing its name in a program statement.} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Advantages of subroutines} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}1. It makes programs {\bf{more efficient}}, because blocks of code can be reused.\{\{nl\}\} 2. It means that code is {\bf{easier to debug}}, because it is shorter.} \tn % Row Count 9 (+ 5) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Parameters}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}A value that is passed to a subroutine. These may also be called 'arguments'.} \tn % Row Count 12 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Procedures}} vs {\bf{Functions}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Both take parameters, but functions return a value, whereas procedures don't.} \tn % Row Count 15 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{{\bf{Local Variables}}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Subroutines can declare local variables, the scope of which is limited to the subroutine. Using local variables is good practice because it allows the program to be simpler. {\bf{Global variables}}, on the other hand, make a program much more complex, as they may change frequently.} \tn % Row Count 22 (+ 7) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.508 cm} x{2.28 cm} x{2.812 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{String Handling}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Pseudocode}} & {\bf{Python Example}} & {\bf{Purpose}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} LEN() & & Find the length of a string. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} POSITION() & \seqsplit{print(string\_to\_search}.find("a")) & To find the position (similar to an index) of a specific character in a string. If the character appears multiple times, only the first instance will be returned. \tn % Row Count 16 (+ 12) % Row 3 \SetRowColor{white} \seqsplit{SUBSTRING(IntExp}, IntExp, StringExp) & & To create a substring. The first paramter indicates the start of the substring, the second the end, and the final parameter being the string itself. \tn % Row Count 27 (+ 11) % Row 4 \SetRowColor{LightBackground} + & firstname + lastname & To concatenate (join) two strings together. \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2.508 cm} x{2.28 cm} x{2.812 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{String Handling (cont)}} \tn % Row 5 \SetRowColor{LightBackground} ORD() & ASCIIcode = ord('a') & To convert a character to character code. \tn % Row Count 3 (+ 3) % Row 6 \SetRowColor{white} CHR() & character = chr(97) & To convert character code to character. \tn % Row Count 6 (+ 3) % Row 7 \SetRowColor{LightBackground} STR() & \seqsplit{str(birthdate)} & To convert a string to an integer. \tn % Row Count 9 (+ 3) % Row 8 \SetRowColor{white} INT() & \seqsplit{int(phonenumber)} & To convert an integer to a string. \tn % Row Count 12 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{8.4cm}}{Note that the pseudocode is not set. Different people will write their psuedocode differently.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Input, Output, and File Handling (Python)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{In Python, the input() function allows a program to receive data from the user. Similarly, print() allows the program to output information to the user. \newline % Row Count 4 (+ 4) {\bf{File handling}} is slightly more complex. A typical file-opening statement would take this format: \newline % Row Count 7 (+ 3) `file\_object = open("filename", "mode")` \newline % Row Count 8 (+ 1) The 'mode' could be 'read' ('r' - allows access only), 'write' ('w' - allows access and editing), or 'appending' ('a' - allows information to be added to the end of the file. \newline % Row Count 12 (+ 4) Once the program has finished using a file, the "filename".close() function should be used, as this frees up resources.% Row Count 15 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Random Number Generation}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{In Python, random number generation requires the importation of the RANDOM module. For example: \newline % Row Count 2 (+ 2) `import random` \newline % Row Count 3 (+ 1) `x = random.randint(0,10)` \newline % Row Count 4 (+ 1) `print(x)`% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}