AP CS A - Summer Work – Part 2
You are suppose to watch each one of the videos in order and answer the questions as you do so. Make
sure you show your work as it has been done in the video. After you complete all questions you should
then do the practice problems on your own. Read the introduction before the videos.
NUMBER SYSTEMS
Introduction
The key aspect of the number systems that we will look at is the base. The base indicates the number of
digits for each place. The one that we use is base 10 (decimal). The 10 digits that we use in this are 0, 1,
2, 3, 4, 5, 6, 7, 8, and 9. Why do we use this over something else like base 2?..... It is for no other reason
than the fact that we are born with 10 fingers and that is what all humans learn to count with.
A number in base b can be converted to its equivalent in base 10 by using place values.
Place Value Formula
b8 b 7 b 6 b5 b 4 b3b 2 b1b 0 .b −1b −2 b −3b −4
Given 1394210, what do the individual digits represent?
13942 10 = 1(10)4 + 3(10)3 + 9(10)2 + 4(10)1 + 2(10)0
= 10,000 + 3000 + 900 + 40 +2
Likewise, the digits in the base 2 number 110101 represent powers of the base 2.
110101 2 = 1(2)5 + 1(2)4 + 0(2)3 + 1(2)2 + 0(2)1 + 1(2)0
= 1(32) + 1(16) + 0(8) + 1(4) + 0(2) + 1(1)
= 32 + 16 + 0 + 4 +0 +1
= 5310
The same can be done for any other base such as converting 13F16 to base ten.
13F16 = 1(16)2 + 3(16)1 + F(16)0
= 1(256) + 3(16) + 15(1)
= 256 + 48 + 15
= 319 10
Write the numbers 1 to 16 in binary as done on the first three examples:
1: 1*20 =0001 2: 1*21 + 0*20 = 0010 3: 1*21 + 1*20 = 0011 4:
5: 6: 7: 8:
9: 10: 11: 12:
13: 14: 15: 16:
AP CS A - Summer Work – Part 2
Video 1: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/number-systems-introduction
1) What number system do we use?
2) Represent 231 as a sum of terms using base 10.
3) How is it called the number system that uses base 2?
4) Follow the steps of the video to represent 12 using base 2.
5) Follow the steps of the video to represent 231 using base 2.
6) What number system uses base 16?
Video 2: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/hexadecimal-number-system
1) Which digits (or symbols) are used in the hexadecimal system?
2) What is the value of each letter in the hexadecimal system?
3) Follow the steps in the video to convert E7 from hexadecimal to decimal.
AP CS A - Summer Work – Part 2
4) Now try to repeat the steps to convert FF(16) and AF3(16) from hexadecimal to decimal.
Video 3: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/decimal-to-binary
1) Represent 13 using the binary system.
Video 4: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/large-number-decimal-to-binary
1) Represent 114 using the binary system.
Video 5: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/decimal-to-hexadecimal
1) Covert 2000 from the decimal system to the binary system
Video 6: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/binary-to-hexadecimal
1) Follow the steps in the video to convert 1011011102 from the binary system to the
hexadecimal system.
AP CS A - Summer Work – Part 2
Converting Numbers to Decimal Equivalents Practice
1012 = 10102 =
1011012 = 1101010.112 =
2716 = 13AD16 =
10716 = 9116 =
Converting from Decimal to BaseX Practice
4710 =___________2 27410 =___________2
AP CS A - Summer Work – Part 2
61210 = ___________2 42510 =___________16
1210 =___________16 2510 =___________16
Converting directly from Binary to Hexadecimal Practice
1011011011101100010110112
1000111010111101011101100100101001012
A7F316
D239AE16
AP CS – Summer Packet – Part 3
Brief introduction of computer architecture
Watch the video https://www.youtube.com/watch?v=HEjPop-aK_w and complete this form.
1) What is the most basic division of a computer system?
2) What is Hardware usually described as?
3) What does software include?
4) What is the other name (mostly used) of a system software?
5) Complete the chart that represents the communication between the user and the hardware.
6) What are the 4 main hardware components?
AP CS – Summer Packet – Part 3
7) Complete the chart that represents the Von Neumann Architecture.
8) What are the two specialized units inside the CPU? What tasks do they perform?
9) The Main memory is volatile. What does that mean?
10) What is normally stored in the main memory?
11) How are the secondary memories like Hard drives, different from the main memory?
AP CS – Summer Packet – Part 3
READ THE NOTES AND WATCH TH VIDEOS IN BETWEEN TO HAVE A BETTER
UNDERSTANDING OF IT. COMPLETE THE ASSIGNED WORK RELATED TO EACH
VIDEO.
Hardware
• The CPU (Central Processing Unit) is made of millions of semiconductor devices, called transistors,
etched into a silicon chip.
• Transistors are combined to form logical devices called gates.
• All digital electronics is basically made up of gates.
Gates
AND gate OR gate NOT gate
A A
A AND B A OR B A NOT A
B B
A B A AND B A B A OR B A NOT A
T T T T T T T F
T F F T F T F T
F T F F T T
F F F F F F
Hardware Terms
• CPU — Central Processing Unit
• RAM — Random-Access Memory “random-access” means the CPU can read directly from and write
to any memory location holds both data and CPU instructions
• ROM — Read-Only Memory holds initialization and hardware diagnostic programs • Peripheral
devices (secondary storage, input/output)
Motherboard
AP CS – Summer Packet – Part 3
Numbers in Memory
• Integers are represented in binary (base 2)
0 00000000
1 00000001
2 00000010
3 00000011
... ...
255 11111111
• Java uses 4 bytes for an integer (int data type)
• For signed numbers, the most significant bit indicates the sign (the leftmost digit)
• Negative numbers are represented in two’s-complement form
• Real numbers are represented as floating-point numbers (similar to scientific notation) with a sign,
binary mantissa (fractional part), and binary exponent.
• Java uses 8 bytes (64 bits) for a “double” (that is, double- precision) floating-point number.
Characters
• Unicode associates characters with numbers (2 bytes represent a character).
• ASCII (American Standard Code for Information Interchange) is a subset comprising the first 128
codes of Unicode:
<space> 32; ‘A’ - ‘Z’ 65 - 90; ‘0’-‘9’ 48-57; ‘a’-‘z’ 97-122
• The first 32 codes are control codes (Carriage Return, Newline, Tab, etc.)
AP CS – Summer Packet – Part 3
As you watch the video https://www.youtube.com/watch?v=OVTu4XcmnwE&t=94s respond the
questions:
1) CPU’s execute instructions in a 4-step cycle. Describe the steps.
2) What is the unit to measure the speed of a CPU?
3) Fill the blanks
Machine code = ________________________________
Instructions are scheduled by the ________________________________
________________ fetches and processes instructions and places the result back into
_____________________ .
PROGRAMMING LANGUAGES
Programming Languages
\ C C++ C#
Assembly LISP Scheme
languages Java D Swift
Algol Logo Ada
1940 1950 1960 1970 1980 1990 2000 2010 2015
Fortran Pascal Python
Machine Basic Fortress Hack
code Cobol Groovy
Smalltalk Smalltalk-80
2-2
AP CS – Summer Packet – Part 3
Thousands of programming languages and dialects have been described; many evolved over the years,
others have disappeared, some existed for years but recently gained new popularity (e.g., Perl, Python).
Java was initially meant for embedded systems (like home appliances) and for “interactive TV” but has
survived due to the Internet.
• Is a formal language designed to communicate instructions to a computer.
• There are two types of programming languages:
• Low Level Languages (machine language and assembly language) – Humans can’t understand.
Machine code is called “first generation”; Assembly languages are second generation;
• High Level Languages are programming languages that computers can’t understand. They look like
English. Ex: C, C++, Java, Python,… They are third generation.
• A HLL must be translated into machine language. The software that does that is a compiler or an
interpreter.
• Compilers take an ENTIRE program (source code) as input and creates all executable instructions
together and as compiled code (object code)
• Interpreters take single instructions as input, create a corresponding machine instruction that is then
executed.
ASSIGNEMENT: WATCH VIDEO https://youtu.be/1OukpDfsuXE . Write a paragraph summarizing
what you learned from this video.
AP CS – Summer Packet – Part 3
BETTER UNDERSTANDING COMPILERS AND INTERPRETERS
Compiler
Source Machine
Code Compiler Code
*.exe
INPUT Run Program OUTPUT
2-5
Compiler
A programming language has a strict syntax. A compiler parses the source code and checks the syntax.
• Compilation initially takes time because it has to translate the whole code into machine language and
save it into the hard disk.
• It creates an executable file called object code. Once compiled, the Operational System can executed
the code over and over again without the need of recompiling.
Interpreter
Interpreter
Source
Code
Interpreter OUTPUT
INPUT
2-7
AP CS – Summer Packet – Part 3
• Interpreter executes a program line by line.
• The only result is the output date. There is no compiled code.
• Every time you want to run the program you need to interpret the code again line by line.
WATCH THE VIDEO https://www.youtube.com/watch?v=_C5AHaS1mOA
Compiled X Interpreted
. Compiled tends to be faster since translation is completed in one step.
. Compiled code does not reveal the original source code.
. Interpreted is more flexible and can be run interactively
• Compiler:
checks syntax
generates machine-code instructions
not needed to run the executable program
the executable runs faster
• Interpreter:
checks syntax
executes appropriate instructions while interpreting the program statements
must remain installed while the program is interpreted
the interpreted program is slower
AP CS – Summer Packet – Part 3
What is Java?
• Java is a high level, object-oriented computer programming language developed by James Gosling in
the mid 1990’s.
• The major difference from Java to many languages is that it was designed to be machine-independent,
that is, a Java program could be written in any platform (Windows, Mac, Linux,..), and then could run in
any platform. WHY?
Java’s Hybrid Approach: Compiler + Interpreter
• A Java compiler converts Java source code into instructions for the Java Virtual Machine.
• These instructions, called bytecode, are the same for any computer/operating system.
• A CPU-specific Java interpreter interprets bytecode
on a particular computer.
Compiled Languages: Interpreted Languages:
Edit-Compile-Link-Run Edit-Run
Editor Source Compiler Object
code code Editor Source Interpreter
Linker Executable code J
program
Editor Source Compiler Object
code code
J
Editor Source Compiler Object
code code
2-13 2-14
ASSIGNMENT: Watch the video https://www.youtube.com/watch?v=GXUiEouK7DM that
explains how Java’s hybrid approach is implemented. Using your own word briefly describe
how that works.
Software Development Tools
• Editor: programmer writes source code (in a language that the computer can’t understand)
• Compiler: translates the source into object code (instructions specific to a particular CPU – or machine
code)
• Linker: converts one or several object modules into an executable program
• Debugger: steps through the program “in slow motion” and helps find logical mistakes (“bugs”).