Variables and data types
|
|
- Jason Carter
- 5 years ago
- Views:
Transcription
1 Programming with Python Module 1 Variables and data types Theoretical part Contents 1 Module overview 4 2 Writing computer programs Computer programs consist of data and instructions Programs have to be translated Writing and executing Python programs Comments Representation of numbers and characters in the computer Binary system Representation of numbers in the binary system Representation of characters in binary system Variables and data types Defining variables Data types of variables Data type of variables in Phyton Operations and expressions Operators Expressions Input and output of data Output in the Python-console
2 6.2 Input via the keyboard Keywords Programming language Algorithm Program Editor Source code Syntax Semantic Compiler Bit/Byte Comments Binary system ASCII code Variable Data type Integer Float String Value assignment Arithmetic operators Screen input and output Authors: Lukas Fässler, Dennis Komm, David Sichau Translation: Christa Furrer Date: 18 July 2018 Version: 1.1 Hash: d2eb005 The authors try the best to provide an error free work, however there still might be some errors. The Authors are thankful for your feedback and suggestions. This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 2
3 To view a copy of this license, visit 3
4 1 Module overview The development of the computer has made it possible that machines perform computing work. However, the computer on its own is not able to solve any problems: we have to prescribe an approach (processing rules). This approach is relayed to the computer in the form of a program. This happens in a special language: the programming language. Processing rules for solving a task are called algorithms. We demand that an algorithm terminates its task and therefore does not run endlessly if it is executed and that it generates a useful output for each input. Hence, algorithm is an abstract term. We can understand, for example, a cake recipe or directions given to a tourist as an algorithm. Here, however, we only consider algorithms that have been formulated in a concrete way in a programming language. 2 Writing computer programs If two people communicate, spoken words are accompanied, for example, by facial expressions and gestures. The answer fine to the question how are you? can be interpreted in different ways depending on the intonation, for example. People have an intellect that enables them to interpret a dialog and to put it in a context. Computers do not have this capability. We have to express ourselves very precisely to communicate with a computer. The computer doesn t know what we actually meant if we expressed ourselves in the wrong way. This was a very laborious work for the first computers because the language a computer understands is not intuitive at all for people. Therefore, so-called standard languages that are closer to our natural language have been developed. To implement algorithms as a computer program, you will use such a language in this course: Python. 2.1 Computer programs consist of data and instructions A computer program is mainly a selection of data and a sequence of instructions which fulfill a certain function when they are executed. Each instruction performs a certain operation, for example a calculation. For a better understanding, you can imagine a cooking recipe as mentioned above. It first contains the quantities of the ingredients (data) and then the order of the steps (instructions) which have to be executed to cook a certain meal. The basic structure of a recipe is almost always the same: first the ingredients then the individual steps. A computer program is very similar to this. Each program also follows a basic pattern. However, we do not speak of a pattern but of the syntax of a programming language, i.e. of the rules that have to be adhered to for the structure of a program. As already mentioned, there are some essential differences to the steps in 4
5 a recipe. The instructions have to be formulated precisely. We will not find instructions such as season to taste here since the computer is not able to interpret them unambiguously. The following line shows a very simple example for the programming language Python: print ("Welcome to programming with Python.") Our program contains in this example: an instruction (the print command print()) the data (in this case the text Welcome to programming with Python). When executing this program now, the following line is output on the screen: Welcome to programming with Python. What the program executes, i.e. its meaning, is called semantics of the program. 2.2 Programs have to be translated Programs in a programming language such as Python are readable and understandable for humans. As already mentioned, a computer doesn t understand them directly but only after a conversion into instructions for its processor. They are not only difficult to understand for us, but also significantly simpler than the commands of a program in a high-level language as Python. This means that a single instruction of a program results in a sequence of several processor instructions. Therefore, the commands of the program have to be translated into instructions of the computer so that the computer is able to execute our program. Special computer programs (so-called compilers) are required to translate programs from a programming language into a sequence of processor instructions. Hence, the process of translating is called compiling Writing and executing Python programs Programs are stored in files. We need an editor to be able to edit and store these files. There are a wide range of editors and development environments for Python. After writing a program, the source code is stored. Files containing Python source code have the extension.py. In the next step, the compiler translates the source code into a format called bytecode which is not visible for the user. It gets the extension.pyc. 5
6 2.2.2 Comments Comments are reading aids for humans. They serve to document the source code. Comments are skipped and completely ignored by the compiler. Any number of comments can be entered. It is necessary to specify where a comment begins and where it ends. In Python, a hash sign (#) at the beginning of the line is used to mark a comment. In the following example, the lines 1, 3 and 4 are ignored by the compiler, but the 2nd line is translated. # This is a comment and it is ignored by the compiler. print("this line is translated by the compiler") # This is also a comment and it is ignored by # the compiler. 3 Representation of numbers and characters in the computer Data which differ in type (e.g. characters, numbers or logical data) are processed in a program. Digital data are always represented by digits. To understand the representation of characters, numbers and texts in the computer, we have to understand the binary system. 3.1 Binary system All computers represent informations in the binary system. It only knows two digits: 0 and 1 (in contrast to the decimal system with digits between 0 and 9). Such a digit is called a bit (abbreviation for binary digit). A bit indicates the smallest storable value in a computer. 8 bits are bundled together into a byte. Therefore, a byte can store 2 8 = 256 different sequences of 8 bit each. 3.2 Representation of numbers in the binary system Consider the number 91 which is represented binarily with 8 bits as (see table 1). Therefore, we talk of the binary representation of 91 (and not of the decimal representation which is easier to read) in this context. An 8-bit number, as in our example, can store values between (0 in the decimal system) and (255 in the decimal system). To convert from the 6
7 Bit Binary value Intrinsic value 2 7 = = = = = = = = 1 Decimal value = 91 Table 1: Binary representation of the decimal number 91. Details see text. binary to the decimal value, we multiply the binary value with the value of the bit (0 or 1) for each bit and add them up. If the number to be represented is larger than 255, we have to provide a larger storage area than 8 bits. 3.3 Representation of characters in binary system For the representation of characters in the computer, the so-called ASCII code was developed. ASCII stands for American Standard Code for Information Interchange. 128 different characters (2 7 ) can be represented with the help of 7-bit ASCII code or, vice versa, each character is assigned a bit pattern of 7 bits (see table 2). The characters largely correspond to those of the computer keyboard. The ASCII code was extended to 8 bits which allows the representation of 256 characters (2 8 ). The ASCII table also contains non-representable characters (such as the character representing a line break). The most important of these are shown in table 3. 4 Variables and data types You can imagine variables as a container for storing values. Variables have names by which they can be invoked and they store a concrete value. The value of the variables can be changed during the execution of the program (it can vary, hence the name). 4.1 Defining variables If you require a variable with the name mynumber you want to store, for example, the value 4 in, you achieve this in Python by using the following command. mynumber = 4 7
8 Dec Characters Dec Characters Dec Characters Dec Characters 0 NUL 32 SP 96 1 SOH 33! 65 A 97 a 2 STX 34 " 66 B 98 b 3 ETX 35 # 67 C 99 c 4 EOT 36 $ 68 D 100 d 5 ENQ 37 % 69 E 101 e 6 ACK 38 & 70 F 102 f 7 BEL G 103 g 8 BS 40 ( 72 H 104 h 9 HT 41 ) 73 I 105 i 10 LF 42 * 74 J 106 j 11 VT K 107 k 12 FF 44, 76 L 108 l 13 CR M 109 m 14 SO N 110 n 15 SI 47 / 79 O 111 o 16 DLE P 112 p 17 DC Q 113 q 18 DC R 114 r 19 DC S 115 s 20 DC T 116 t 21 NAK U 117 u 22 SYN V 118 v 23 ETB W 119 w 24 CAN X 120 x 25 EM Y 121 y 26 SUB 58 : 90 Z 122 z 27 ESC 59 ; 91 [ 123 { 28 FS 60 < 92 \ GS 61 = 93 ] 125 } 30 RS 62 > 94 ˆ 126 ~ 31 US 63? 95 _ 127 DEL Table 2: ASCII table 8
9 Dec Characters Meaning 8 BS Backspace. Deleting the character to the left 10 NL New Line. Beginning a new line 32 SP Space. 127 DEL Delete. Deleting the character to the right Table 3: Non-representable characters of the ASCII table Storing values is done with the assignment operator. In Python, as in many programming languages, the equal sign (=) is used for it. Thereby, the value of the expression to the right of the assignment operator is assigned to the variable on the left-hand side. The process of assigning a value to the variable for the first time is called initialization of the variable. As mentioned previously, the value of a variable can change during the execution of the program. Let s have a look at the following example: First, we store the value 4 in the variable mynumber and then we overwrite it with the value 6 in a further line. mynumber = 4 # Value of mynumber is 4 mynumber = 6 # Value of mynumber is Data types of variables The data type indicates which data can be stored in a variable. Programming languages have predefined data types which differ in the way they interpret the stored data and in their size. Most programming languages distinguish the following data types. Type for numerical values Type for character values Type for truth values Table 4 provides an overview of the most important data types which occur in many programming languages. 9
10 Type Description Example boolean Truth value True or False int Integer 108, -455 float Floating-point number 8.988, string character string "Monday", "7.9" Table 4: The most important data types in Python 4.3 Data type of variables in Phyton Unlike in many other programming languages, the data type of a variable does not have to be defined at the start. This means, you only need to name a variable (as described above). The type of the variable is later defined automatically based on the type of the value during the run time. The following example shows a variable a, the data type of which is defined as integer, a variable b, the data type of which is defined as float, and a variable c, the data type of which is defined as string. a = 4 # a is defined as integer b = 0.1 # b is defined as float c = "Monday" # c is defined as string When defining string variables, the value has to be enclosed in double quotes ("). Several strings can be concatenated by using a plus (+). For example, a new text that is stored in the variable d results from several individual parts. d = "Hello, " + " these " + "are " + "several " + "words." Although the data types are determined automatically in Python, it can nevertheless be useful to know the data type for some tasks. By using the following command, the data type of a variable d can be displayed. type(d) 10
11 The data type of variables can also change during the execution of the program. In the following example, the variable a initially has the type integer but then changes to the type float. a = 1 # a is defined as integer a = a # a is defined as float The data type of a variable can be changed explicitly. In the following example, the data type of a variable a is first defined as float and then changed to integer. a = 1.9 # a is defined as float a = int(a) # a is defined as integer. The value is 1 now. 5 Operations and expressions 5.1 Operators To perform calculations in a program, various arithmetic operators are available (see table 5). Operator Expression Description Provides Example + a + b Addition Sum = 7 - a - b Subtraction Difference 5-2 = 3 a b Multiplication Product 5 2 = 10 / a / b Division Quotient 5 / 2 = 2.5 % a % b Modulo Integer remainder of a division 5 % 2 = 1 Table 5: Arithmetic operators in Python Further operators (logical and relational operators) are introduced in module 2. 11
12 5.2 Expressions Expressions in programming language are part of the smallest executable units of a program. They are process specifications that can consist of variables, constants and operators and lead to a result. Variables and constants that are concatenated with an operator are called operands. An expression can also consist of an individual variable. The following example shows an expression consisting of a variable i, an operator + and a constant 5. Therefore, i and 5 are operands. i + 5 The result of the expression can again be stored in a variable. In the following example, we use the variable i. Therefore, the previous value of i is overwritten. i = i + 5 The order in which the expressions are executed can be influenced by the choice of the operator and by using brackets. For this, the mathematical rules as we learnt them at school apply, i.e. first brackets and then multiplication/division before addition/subtraction. Example: 5 * (2 + 10) The brackets make sure that the addition is executed before the multiplication. 6 Input and output of data It is often desirable that a user of the program can interact with the program. For this purpose, almost every programming language has special input and output functions. This means that the user can enter something (for example via the keyboard) or that the program performs an output (for example the result of a calculation or a text). 6.1 Output in the Python-console By the following function, which we have already used above, we can output the text "The program ends here." in the console: 12
13 print("the program ends here.") However, we may sometimes not want to output a given text, but, for example, the result of a calculation stored in a variable (e.g. myresult). The following function outputs the value of the variable myresult in the console: print(myresultat) Variable values and text can be connected with a comma (,) in Python. print(myresult, "was calculated.") 6.2 Input via the keyboard Most programs require an input at some stage. This can be done in different ways (data base, internet, etc.). A common form of input is via the keyboard of the user. A user input via the keyboard can be made in Python by using the function input(). The following command stops the program execution until the user makes an input and confirms it with the return key. a = (input("what s your name?")) First, the string which is enclosed by brackets is output so that the user knows what he or she has to enter. The function input() always provides a string which can be stored in a variable. If another data type is desired for the keyboard input, it must be changed explicitly. b = int(input("how much do you want? ")) # Data type of b shall be integer c = float(input("what does the piece cost? ")) # Data type of c shall be float 13
Fundamentals of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamentals of Programming (C) Group 8 Lecturer: Vahid Khodabakhshi Lecture Number Systems Department of Computer Engineering Outline Numeral Systems
More information1.1. INTRODUCTION 1.2. NUMBER SYSTEMS
Chapter 1. 1.1. INTRODUCTION Digital computers have brought about the information age that we live in today. Computers are important tools because they can locate and process enormous amounts of information
More informationData Representation and Binary Arithmetic. Lecture 2
Data Representation and Binary Arithmetic Lecture 2 Computer Data Data is stored as binary; 0 s and 1 s Because two-state ( 0 & 1 ) logic elements can be manufactured easily Bit: binary digit (smallest
More informationUnit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School
Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program
More informationBits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.
Bits and Bytes 1 A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices. A byte is a sequence of 8 bits. A byte is also the fundamental unit of storage
More informationFundamentals of Programming
Fundamentals of Programming Lecture 2 Number Systems & Arithmetic Lecturer : Ebrahim Jahandar Some Parts borrowed from slides by IETC1011-Yourk University Common Number Systems System Base Symbols Used
More informationChapter 2 Bits, Data Types, and Operations
Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two
More informationNumbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras
Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15
More informationCPS 104 Computer Organization and Programming Lecture-2 : Data representations,
CPS 104 Computer Organization and Programming Lecture-2 : Data representations, Sep. 1, 1999 Dietolf Ramm http://www.cs.duke.edu/~dr/cps104.html CPS104 Lec2.1 GK&DR Fall 1999 Data Representation Computers
More informationNumber Representations
Simple Arithmetic [Arithm Notes] Number representations Signed numbers Sign-magnitude, ones and twos complement Arithmetic Addition, subtraction, negation, overflow MIPS instructions Logic operations MIPS
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize
More informationNumber System (Different Ways To Say How Many) Fall 2016
Number System (Different Ways To Say How Many) Fall 2016 Introduction to Information and Communication Technologies CSD 102 Email: mehwish.fatima@ciitlahore.edu.pk Website: https://sites.google.com/a/ciitlahore.edu.pk/ict/
More informationCS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON
CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Pradip Vallathol and Junaid Khalid Midterm Examination 1 In Class (50 minutes) Friday, September
More informationCS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON
CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Junaid Khalid and Pradip Vallathol Midterm Examination 1 In Class (50 minutes) Friday, September
More informationBinary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example
The Basics Binary Numbers Part Bit of This and a Bit of That What is a Number? Base Number We use the Hindu-Arabic Number System positional grouping system each position represents a power of Binary numbers
More informationDATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes
1 DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations Other Binary Codes Error Detection Codes 2 Data Types DATA REPRESENTATION Information that a Computer
More informationCMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes
Multiple-byte data CMSC 313 Lecture 03 big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes UMBC, CMSC313, Richard Chang 4-5 Chapter
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, S. Rajopadhye Colorado State University How do we represent data
More informationChapter 3. Information Representation
Chapter 3 Information Representation Instruction Set Architecture APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL 3 MICROCODE LEVEL
More informationChapter 2 Number System
Chapter 2 Number System Embedded Systems with ARM Cortext-M Updated: Tuesday, January 16, 2018 What you should know.. Before coming to this class Decimal Binary Octal Hex 0 0000 00 0x0 1 0001 01 0x1 2
More informationASSIGNMENT 5 TIPS AND TRICKS
ASSIGNMENT 5 TIPS AND TRICKS linear-feedback shift registers Java implementation a simple encryption scheme http://princeton.edu/~cos26 Last updated on /26/7 : PM Goals OOP: implement a data type; write
More informationChapter 8. Characters and Strings
Chapter 8 Characters and s OJECTIVES After you have read and studied this chapter, you should be able to Declare and manipulate data of the char data type. Write string processing programs using and uffer
More informationThe Binary Number System
The Binary Number System Robert B. Heckendorn University of Idaho August 24, 2017 Numbers are said to be represented by a place-value system, where the value of a symbol depends on where it is... its place.
More informationNumber Systems Base r
King Fahd University of Petroleum & Minerals Computer Engineering Dept COE 2 Fundamentals of Computer Engineering Term 22 Dr. Ashraf S. Hasan Mahmoud Rm 22-44 Ext. 724 Email: ashraf@ccse.kfupm.edu.sa 3/7/23
More informationOberon Data Types. Matteo Corti. December 5, 2001
Oberon Data Types Matteo Corti corti@inf.ethz.ch December 5, 2001 1 Introduction This document is aimed at students without any previous programming experience. We briefly describe some data types of the
More informationLecture (09) x86 programming 8
Lecture (09) x86 programming 8 By: Dr. Ahmed ElShafee 1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Computer is a binary digital system. Digital system: finite number of symbols Binary (base two) system: has two states: 0 and 1 Basic unit of information is the
More informationplc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums
plc numbers - 3. 3. NUMBERS AND DATA Topics: Number bases; binary, octal,, hexa Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;
More informationNumber Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers
Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We
More informationExperiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.
Experiment 3 Introduction: In this experiment the students are exposed to the structure of an assembly language program and the definition of data variables and constants. Objectives: Assembly language
More informationPositional Number System
Positional Number System A number is represented by a string of digits where each digit position has an associated weight. The weight is based on the radix of the number system. Some common radices: Decimal.
More informationUNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES
UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES Structure 2.0 Introduction 2.1 Unit Objectives 2.2 Number Systems 2.3 Bits and Bytes 2.4 Binary Number System 2.5 Decimal Number System 2.6 Octal Number System
More informationIntroduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators
Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program
More informationReview. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale
Review Single Pixel Filters Thresholding Posterize Histogram Equalization Negative Sepia Grayscale Spatial Filters Smooth Blur Low Pass Filter Sharpen High Pass Filter Erosion Dilation Image Processing
More informationSource coding and compression
Computer Mathematics Week 5 Source coding and compression College of Information Science and Engineering Ritsumeikan University last week binary representations of signed numbers sign-magnitude, biased
More informationData Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?
CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,
More informationExercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014
Exercises Software Development I 03 Data Representation Data types, range of values, ernal format, literals October 22nd, 2014 Software Development I Wer term 2013/2014 Priv.-Doz. Dipl.-Ing. Dr. Andreas
More informationSimple Data Types in C. Alan L. Cox
Simple Data Types in C Alan L. Cox alc@rice.edu Objectives Be able to explain to others what a data type is Be able to use basic data types in C programs Be able to see the inaccuracies and limitations
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012
CMSC 33 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 2, FALL 22 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point formats
More information5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital
Chapter 8: Bits and the "Why" of Bytes: Representing Information Digitally Digitizing Discrete Information Fluency with Information Technology Third Edition by Lawrence Snyder Copyright 2008 Pearson Education,
More informationConnecting UniOP to Datalogic Barcode Readers
Connecting UniOP to Datalogic Barcode Readers This Technical Note contains the information needed to connect UniOP to Datalogic Barcode Scanners. Contents 1. Introduction...1 2. Designer setup...1 2.1
More informationCSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.
9 February 2011 CSE-1520R Test #1 [7F] w/ answers p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The
More informationData Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?
CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,
More informationCSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.
9 February 2011 CSE-1520R Test #1 [B4] p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The exam is closed
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationChapter 1. Hardware. Introduction to Computers and Programming. Chapter 1.2
Chapter Introduction to Computers and Programming Hardware Chapter.2 Hardware Categories Input Devices Process Devices Output Devices Store Devices /2/27 Sacramento State - CSc A 3 Storage Devices Primary
More informationCS341 *** TURN OFF ALL CELLPHONES *** Practice NAME
CS341 *** TURN OFF ALL CELLPHONES *** Practice Final Exam B. Wilson NAME OPEN BOOK / OPEN NOTES: I GIVE PARTIAL CREDIT! SHOW ALL WORK! 1. Processor Architecture (20 points) a. In a Harvard architecture
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationFundamental Data Types
Fundamental Data Types Lecture 4 Sections 2.7-2.10 Robb T. Koether Hampden-Sydney College Mon, Sep 3, 2018 Robb T. Koether (Hampden-Sydney College) Fundamental Data Types Mon, Sep 3, 2018 1 / 25 1 Integers
More informationvoid mouseclicked() { // Called when the mouse is pressed and released // at the same mouse position }
Review Commenting your code Random numbers and printing messages mousex, mousey void setup() & void draw() framerate(), loop(), noloop() Arcs, curves, bézier curves, beginshape/endshape Example Sketches
More information1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1
Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 1. Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 2. Numeric Representation of
More informationArrays. Theoretical Part. Contents. Keywords. Programming with Java module 3
Programming with Java module 3 Arrays Theoretical Part Contents 1 Module Overview 3 1.1 One-dimensional arrays.......................... 3 1.2 Declaring arrays............................... 3 1.3 Generating
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationNumber Systems II MA1S1. Tristan McLoughlin. November 30, 2013
Number Systems II MA1S1 Tristan McLoughlin November 30, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/18 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii
More informationUnder the Hood: Data Representation. Computer Science 104 Lecture 2
Under the Hood: Data Representation Computer Science 104 Lecture 2 Admin Piazza, Sakai Up Everyone should have access Homework 1 Posted Due Feb 6 PDF or Plain Text Only: No Word or RTF Recommended: Learn
More informationHardware. ( Not so hard really )
Hardware ( Not so hard really ) Introduction to Computers What is a computer? Why use a computer anyway? Do they have limitations? What s next? A bit of history Mechanical Early 1614 1643 1673 Abacus Slide
More informationEE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL
EE 9 Unit Binary Representation Systems ANALOG VS. DIGITAL Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world is based on discrete
More informationEXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)
EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: Introduction To understand and apply USART command for sending and receiving data Universal Serial Asynchronous
More information2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme
2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme repeated (integer) division by two. Example: What is
More informationControl structures and logic
Programming with Java Module 2 Control structures and logic Theoretical part Contents 1 Module overview 3 1.1 Commands and blocks........................... 3 2 Operators (Part II) 4 2.1 Relational Operators............................
More informationEE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL
3. 3. EE 9 Unit 3 Binary Representation Systems ANALOG VS. DIGITAL 3.3 3. Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world
More informationEXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)
EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: To understand and apply USART command for sending and receiving data Introduction Universal Serial Asynchronous
More informationUnit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation
3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based
More informationIntroduction. Chapter 1. Hardware. Introduction. Creators of Software. Hardware. Introduction to Computers and Programming (Fall 2015, CSUS)
Chapter Introduction Introduction to Computers and Programming (Fall 25, CSUS) Chapter. Introduction Creators of Software Computers perform any job that their programs tell them to do A program is a set
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point
More informationCS 159 Credit Exam. What advice do you have for students who have previously programmed in another language like JAVA or C++?
CS 159 Credit Exam An increasing number of students entering the First Year Engineering program at Purdue University are bringing with them previous programming experience and a many of these students
More informationPureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -
PureScan - ML1 Wireless Linear Imager Wireless Laser scanner Configuration Guide - 1 - Table of Contents Chapter 1 System Information 1.1 About this manual 3 1.2 How to set up the parameter 3 Chapter 2
More informationUser s Manual. Xi3000 Scanner. Table of Contents
Xi3000 Scanner User s Manual Table of Contents Restore Default Settings... 1 Exit Setup without Changes... 1 Configure Through RS232... 1 List Setting... 1 Buzzer Settings... 2 Reading Redundancy Setting...
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationFA269 - DIGITAL MEDIA AND CULTURE
FA269 - DIGITAL MEDIA AND CULTURE ST. LAWRENCE UNIVERSITY a. hauber http://blogs.stlawu.edu/digitalmedia DIGITAL TECHNICAL PRIMER INCLUDED HERE ARE THE FOLLOWING TOPICS A. WHAT IS A COMPUTER? B. THE DIFFERENCE
More informationEE 109 Unit 2. Binary Representation Systems
EE 09 Unit 2 Binary Representation Systems ANALOG VS. DIGITAL 2 3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based
More informationUniversal Asynchronous Receiver Transmitter Communication
Universal Asynchronous Receiver Transmitter Communication 13 October 2011 Synchronous Serial Standard SPI I 2 C Asynchronous Serial Standard UART Asynchronous Resynchronization Asynchronous Data Transmission
More informationo Echo the input directly to the output o Put all lower-case letters in upper case o Put the first letter of each word in upper case
Overview of Today s Lecture Lecture 2: Character Input/Output in C Prof. David August COS 217 http://www.cs.princeton.edu/courses/archive/fall07/cos217/ Goals of the lecture o Important C constructs Program
More informationCharacters Lesson Outline
Outline 1. Outline 2. Numeric Encoding of Non-numeric Data #1 3. Numeric Encoding of Non-numeric Data #2 4. Representing Characters 5. How Characters Are Represented #1 6. How Characters Are Represented
More informationProgrammable #182 Parallel Interface Cash Drawer Manual
Programmable #182 Parallel Interface Cash Drawer Manual The following warning is required by the FCC for all Class A computing devices which have been tested and comply with the standard indicated: Warning:
More informationChapter 7. Binary, octal and hexadecimal numbers
Chapter 7. Binary, octal and hexadecimal numbers This material is covered in the books: Nelson Magor Cooke et al, Basic mathematics for electronics (7th edition), Glencoe, Lake Forest, Ill., 1992. [Hamilton
More information3.1. Unit 3. Binary Representation
3.1 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.2 3.3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based on discrete
More informationXi2000-BT Series Configuration Guide
U.S. Default Settings Sequence Reset Scanner Xi2000-BT Series Configuration Guide Auto-Sense Mode ON UPC-A Convert to EAN-13 OFF UPC-E Lead Zero ON Save Changes POS-X, Inc. 2130 Grant St. Bellingham, WA
More informationConfiguration Manual PULSAR C CCD SCANNER. Table of Contents
Table of Contents PULSAR C CCD SCANNER Configuration Manual Metrologic Instruments GmbH Dornier Strasse 2 82178 Puchheim Germany Tel +49 89 890190 Fax +49 89 89019200 www.europe.metrologic.com Metrologic
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012 ANNOUNCEMENTS TA Office Hours (ITE 334): Genaro Hernandez, Jr. Mon 10am 12noon Roshan Ghumare Wed 10am 12noon Prof.
More informationThe following are the data types used in the C programming language:
Data Types in C The following are the data types used in the C programming language: Type Definition Size in memory void This particular type is used only in function declaration. boolean It stores false
More informationWeek 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals. Alvin Valera. School of Engineering and Computer Science Victoria University of Wellington
Week 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals Alvin Valera School of Engineering and Computer Science Victoria University of Wellington Admin stuff People Course Coordinator Lecturer Alvin Valera
More information4/14/2015. Architecture of the World Wide Web. During this session we will discuss: Structure of the World Wide Web
Internet Gambling Investigations Architecture of the World Wide Web Ω Objectives During this session we will discuss: The term world wide web User interaction on the world wide web The purpose of gateways
More informationRS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200
RS-232 Control of the Advantage EQ281/8, EQ282/8 and Advantage SMS200 Biamp Systems, 14130 N.W. Science Park, Portland, Oregon 97229 U.S.A. (503) 641-7287 an affiliate of Rauland-Borg Corp. Introduction
More informationCPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation
CPSC 301: Computing in the Life Sciences Lecture Notes 16: Data Representation George Tsiknis University of British Columbia Department of Computer Science Winter Term 2, 2015-2016 Last updated: 04/04/2016
More informationRS-232 Digital Relay I/O
RS-232 Digital Relay I/O Model 232DRIO Documentation Number 232DRIO1005 pn#4520-r2 This product Designed and Manufactured In Ottawa, Illinois USA of domestic and imported parts by B&B Electronics Mfg.
More informationTable of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup
Table of Contents Chapter 1 System Information 1.1 Setup Scanner with PC 1.2 Setup Scanner with Mobile Device 1.3 Configure ios On-Screen Keyboard 1.4 Memory Mode 3 4 4 5 1.5 Sleep Settings 6 1.6 How to
More informationThis is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.
Dealing With ASCII ASCII, of course, is the numeric representation of letters used in most computers. In ASCII, there is a number for each character in a message. Max does not use ACSII very much. In the
More informationUser s Manual. Addendum to. Ranger Wedge Interface. Part No. 25-WEDGE-06A Ver. April 1999
Addendum to User s Manual Ranger Wedge Interface Part No. 25-WEDGE-06A Ver. April 1999 8 Olympic Drive Orangeburg, NY 10962 Tel 845.365.0090 Fax 845.365.1251 www.opticonusa.com Table of Contents Read Me
More informationAPPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5
APPENDIX A : KEYWORDS... 2 APPENDIX B : OPERATORS... 3 APPENDIX C : OPERATOR PRECEDENCE... 4 APPENDIX D : ESCAPE SEQUENCES... 5 APPENDIX E : ASCII CHARACTER SET... 6 APPENDIX F : USING THE GCC COMPILER
More informationn NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i
Instruction set Instruction Mnemonic Instruction Addressing Status Specifier Mode Bits 0000 0000 STOP Stop execution U 0000 0001 RET Return from CALL U 0000 0010 RETTR Return from trap U 0000 0011 MOVSPA
More informationObjects. Theoretical Part. Contents. Keywords. Programming with Java Module 5. 1 Module Overview 3
Programming with Java Module 5 Objects Theoretical Part Contents 1 Module Overview 3 2 Classes and Objects 3 2.1 Classes.................................... 4 2.2 Object variables and methods......................
More information8.2 User Defined Protocol Communication
8.2 User Defined Protocol Communication 8.2.1 Introduction User Defined Protocol Communication allows users who do communication between GM7 Basic Unit and other kind of device to define the other company
More informationMidterm CSE 131 Winter 2012
Login Name Signature _ Name Student ID Midterm CSE 131 Winter 2012 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 (22 points) (29 points) (25 points) (34 points) (20 points) (18 points) Subtotal (148 points
More informationCMPSC 311- Introduction to Systems Programming Module: Strings
CMPSC 311- Introduction to Systems Programming Module: Strings Professor Patrick McDaniel Fall 2014 A string is just an array... C handles ASCII text through strings A string is just an array of characters
More informationFD-011WU. 2D Barcode Reader User Guide V1.6CC
FD-011WU 2D Barcode Reader User Guide V1.6CC Table of Contents 1 Getting Started... 1 1.1 Factory Defaults... 1 2 Communication Interfaces...2 2.1 TTL-232 Interface... 2 2.2 Baud Rate... 3 2.3 Data Bit
More information