0% found this document useful (0 votes)
8 views

02_Cisco_Chapter_1_Lecture (Module 1 Lecture 2)

The document outlines the content of a Cisco lecture, focusing on programming fundamentals and Python language specifics. It discusses various number systems (decimal, binary, octal, hexadecimal), high-level vs low-level programming languages, and the importance of detail in programming. Additionally, it highlights Python's compatibility issues and the role of IDEs in development.

Uploaded by

corvuscivis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

02_Cisco_Chapter_1_Lecture (Module 1 Lecture 2)

The document outlines the content of a Cisco lecture, focusing on programming fundamentals and Python language specifics. It discusses various number systems (decimal, binary, octal, hexadecimal), high-level vs low-level programming languages, and the importance of detail in programming. Additionally, it highlights Python's compatibility issues and the role of IDEs in development.

Uploaded by

corvuscivis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Cisco Chapter 1 Lecture 1

(Module 1 Lecture 2)
And Murach Chapter 1

https://youtu.be/CkOOazEJcUc?t=91
https://youtu.be/CkOOazEJcUc?t=92 1:31

02_Cisco_Chapter_1_Lecture
Announcement-type things…
• If there is a line of code that crashed your program, please comment
that out so the first time I run the code it works out of the box. That
way I know that you know that line of code was no good. (But leave it
there, it counts as an experiment!)
• Feel free to overwrite any placeholder files I have left in your turn it in
folder. Some will need to rename their 001_C file.
• First two lines of each .py file:
#!/usr/bin/env python3
#Dave Kerr
• #Experiments Below ----------
A Typo That Cost NASA Over $600 Million – Youtube accessed March 2019
Review
1. What two resources do you need as “textbooks” for this class?
2. Where can you see all the files you will need to hand in for this
course?
3. What are the two places you need to go to hand in homework?
Three Questions For today:
1. What is not backwards compatible with Python?
2. What are two base-languages that Python flavors are built on?
3. What do these mean - and which do you think is easier to
understand? 0x and 0o
Programming is detail-oriented - let’s not
waste $150,000,000! 
• Don’t assume you did it correctly the first time! 
• and don’t use punch cards!
• https://youtu.be/CkOOazEJcUc?t=91
• https://youtu.be/CkOOazEJcUc?t=92 1:31
Decimal, Binary, Octal, and
Hexadecimal Counting Systems
• Decimal (Deci means 10) – your normal numbering 0 – 9 (note that is ten #’s)
• 0-9 fits in one column. When filled it goes back to zero and the next column gets a bump up
right? 009 + 1 = 010 and 099 + 1 = 100
• Binary (Bi means two) uses 0 or 1 in a column
• 0 or 1 in one column. When the column is filled, it bumps the next one up. 00000001 +1 =
00000010 and 00001111 + 1 = 00010000
• Octal (Oct means 8) uses 0 – 7, usually denoted “0o” like 0o52
• 0-7 fits in one column. 0o007 + 0o001 = 0o010
• Hexidecimal (Hex means six, Deci means 10, together =16) 0 – 9, A,B,C,D,E and F
• 0 – F fits in one column. Denoted “0x” like 0x52 or 0x5F4D1
• 0x000F + 1 = 0x0010, 0x00FF + 1 = 0x0100
• 0x0009 + 1 = 0x000A, 0x000B + 1 = 0x000C
Each row has the same value, 8-bit byte version
Decimal Binary Octal Hexadecimal

0 00000000 0o000 0x00

1 00000001 0o001 0x01

2 00000010 0o002 0x02

3 00000011 0o003 0x03

4 00000100 0o004 0x04

5 00000101 0o005 0x05

6 00000110 0o006 0x06

7 00000111 0o007 0x07

8 00001000 0o008 0x08

9 00001001 0o009 0x09

10 00001010 0o010 0x0A

11 00001011 0o011 0x0B

12 00001100 0o012 0x0C

13 00001101 0o013 0x0D

14 00001110 0o014 0x0E

15 00001111 0o015 0x0F

255 11111111 0o377 0xFF


High Level vs Low Level
programming languages
• Refers to how close to the chips and binary you are:
• High level – far away from the chip, much closer to eth way
you talk. This language uses words we understand and are
much easier to learn. However, they are slower because the
computer has to translate them into lower level languages.
Python, PERL, and Ruby are high-level languages. File called
a “source file”
• Low level – close to the chip. Machine coding (raw Binary or
Hexidecimal) is lowest level, and almost no one does that.
Can be seen in CAD machines or other robotic machines
today. The C language is closer to low level than Python is,
but is still considered high level. X86 and Assembly Code are
low-level.
• A file = Machine code (example = .exe file in Windows)
Practice conversions?
What elements make a language?
• Alphabet: A-Z, and perhaps 0-9 (Rem: Elon Musk’s daughter!)?
• Lexis: fancy word for “vocabulary”
• Syntax: word –ordering
• I to the store am going, I am going to the store.
• Semantics: Meaning of that word-order
• That’s cold! (Rude? Freezing?)
• That’s cool! (Great? Freezing?)
• "There should be one, and preferably only one, obvious way to do it“
(Python – i.e. indentation, quotes, parentheses …)
• There should be more ways than one… (PERL & Ruby
Which of these will work in Python?
1. print ()
2. Print ()
3. print(“Hello World”)
4. prin(“Hello World”)
5. print(‘Hello World’)
6. print(Hello World)
7. Print “Hello World”
Compile vs Interpretation https://youtu.be/JNMy969SjyU

• Compilation – the source • Interpretation – you (or any user


program is translated once of the code) can translate the
(however, this act must be source program each time it has
repeated each time you modify to be run. The program
the source code) by getting a performing this kind of
file (e.g., an .exe file if the code transformation is called
is intended to be run under MS an interpreter, as it interprets the
Windows) containing the code every time it is intended to
machine code. Now you can be executed. It also means that
distribute the file worldwide; the you cannot just distribute the
program that performs this source code as-is, because the
translation is called
a compiler or translator. end-user also needs the
interpreter to execute it.
Compile (MSWord.exe)
Code  Compiler  .exe for
distribution or testing

Interpret:
Python code  Python.exe 
Binary  kernel
IDE’s (Integrated Development Environment)
IDLE = Integrated Dev and Learning Envmt
• Integrates a console, an editor, and a debugger, and maybe more!
• Console = window where you see output from your program and helps you
interact with your OS and execute commands.
• Editor = Where you develop your program – usually points out errors
• Debugger = helps you stop and start your program and see what the
variables are changing to without you having to restart every time you
want to see something.

• Compiler: When you are ready to run the program on your computer you
need it in machine code. This does that job automatically.
• Interpreter: Also compiles, but sends the code straight to the computer –
you do not need the entire program to run a part of it.
Scripting
• A text file containing instructions
• Usually code that coordinates other code (automation)

• Python is used extensively for scripting. One program will be running,


then call on another Python program to help do the job.

• This also makes Python excellent for creating and executing tests for
applications.
Compatibility of Python Flavors
• Java vs. C compatibility
• Almost all versions of Python are written to compile/interpet through C.
• A few are highly modified to use languages such as Java.
• *Either way, the source code is written in Python, and the performance is based
upon how good the interpreter is. Python source code (what you write) for Java will
be identical to that for C.

• Forward and Backward compatibility


• Python 3 is written to be forward compatible (hopefully). All versions with a 3 in
front work with each other.
• Python 2 does not work with Python 3. 
• Python 2 is not forward compatible, and Python 3 is not backward compatible  
• (I think that is a major flaw, but that might be because I am old. )
Good luck on your Quiz! Set phone alarm?
Three Questions:
1. What is not backwards compatible with Python?
2. What are two base-languages that Python flavors are built on?
3. What do these mean - and which do you think is easier to
understand? 0x and 0o

You might also like