Unit 1 Flashcards
What is a web crawler? How does it work?
A web crawler is a program that collects content from the web. A web crawler finds web pages by starting from a seed page and where it collects the desired content plus all of the links on the page. It then follows the links to other pages, collecting content a links, following those links, and repeating the process over and over.
What is a computer?
A machine that can execute a program. With the right program, a computer can do any mechanical computation you can imagine.
What is a program?
A program is instructions that tell the computer what to do by describing a very precise sequences of steps. Since the computer is just a machine, the program must give the steps in a way that can be executed mechanically. That is, the program can be followed without any thought.
What is a programming language?
A programming language is a language designed for producing computer programs. A good programming language makes it easy for humans to read and write programs that can be executed by a computer.
What is Python?
Python is a programming language. The programs written in Python will be the input to the Python interpreter, which is a program that runs on the computer. The Python interpreter reads our programs and executes them by following the rules of the Python language.
What is an expression in Python? What is one rule of the Python grammar for making expressions?
An expression is something that has a value. One rule of the Python grammar for making expressions is:
Expression ==> Expression Operator Expression
Expression ==> Expression Operator Expression
What type of definition is this an example of? What are the two rules you need to make this type of definition and why is this type of definition important?
This is an example of a recursive definition. To make a good recursive definition you need at least two rules:
- A rule that defines something in with terms referring to itself.
Expression ==> Expression Operator Expression - A rule that defines that thing in terms of something else that we already know.
Expression ==> Number
Number ==> 0, 1, 2, . . .
Operator ==> +
Recursive definitions are a very powerful idea in computer science. They allow us to define infinitely many things using a few simple rules.
How does Python perform integer division?
When you divide an integer (a number without decimals) by another integer Python performs integer division, which means it will ignore the decimal part of the answer. To force Python to give an answer with a decimal you have to make one of the number into a decimal, or a floating point number.
What is the processor? Why must processors get smaller as they get faster?
A processor is the part of the computer that carries out the steps specified in a computer program. Sometimes called the central processing unit, or CPU. As processors get faster they execute more cycles each second. The electric current, moving at the speed of light, must run through the entire processor each cycle. If the processor is a 2.7 GHz processor, electricity will need to cycle through the processor 2.7 billion times each second. So each cycle will need to be 1/2,700,000,000 (one-two-billion-seven-hundred-millionth) of a second long. In that length of time, light will travel about 11 cm. If the processor was any bigger than that size, the electric current could not cycle through the entire processor before the next cycle needed to being. This would limit the processor speed to something slow enough to account for the distance the light needed to travel each cycle.
What is a variable? What does Python use as variables?
A variable is a name that refers to a value. In Python, we can use any sequence of letters and numbers and underscores ( _ ) we want to make a variable name, so long as it does not start with a number.
What do you use to introduce a new variable? What does executing this thing cause to happen?
You use assignment statements to introduce a new variable. After executing an assignment expression, the name refers to the value of the expression on the right side of the assignment.
speed_of_light = 299792458
What is a special characteristic of variable’s reference property?
The value of a variable can change. When a variable name is used, it always refers to the last value assigned to that variable. Since the value that a variable refers to can change, that same exact expression can have different values at the different times it is executed.
Remember that the “ = “ means assigned more than equals in Python. Equals is show with “==”.
What is a string?
A string is a sequence of characters surrounded by quotes; either single or double.
‘This is a string’
How is the plus operator used with strings? How is the multiplication operator used with strings?
The plus operator concatenates two strings and the multiplication operator can replicate a string multiple times, like when printing.
print ‘hel’ + ‘lo’
hello
print ‘hello’ * 3
hellohellohello
What is string indexing? What does a negative number do with string indexing?
Indexing is the system used for selecting sub-sequences from strings. Square brackets ( […] ) are used to specify which part of the string you want to select.
[]
print ‘string’[0]
s
Negative numbers cause the index to start counting from the back of the string.
print ‘string’[2] + ‘string’[-1]
tg