Shared Flashcard Set

Details

python
programming
40
Computer Science
12th Grade
03/13/2018

Additional Computer Science Flashcards

 


 

Cards

Term
syntax
Definition
the arrangement of words and phrases to create well-formed sentences in a language
Term
static semantics
Definition
the part that can be ascertained at compile time, including data typing, whether all variable are declared, which declaration applies to which variable in the case of scoping, what their type is, whether functions and methods are called with correct calling sequences, whether assignments 
Term
Literals
Definition
iterals include the string, unicode string, integer, float, long, list, tuple and dictionary types.
Term
Infix Operators
Definition

 

(e.g., + and /). 

Term
Semantics
Definition
is the field concerned with the rigorous mathematical study of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved.
Term
Source Code
Definition
  1. a text listing of commands to be compiled or assembled into an executable computer program.
Term
Machine Code
Definition
  1. a computer programming language consisting of binary or hexadecimal instructions that a computer can respond to directly.
Term
Script
Definition
 a list of commands that can be executed without user interaction.
Term
Python Program
Definition

 

is a sequence of definitions and commands. These definitions are evaluated and the commands are executed by the interpreter in something called the shell.

 

Term
Shell
Definition

 

Typically, a new shell is created whenever execution of a program begins. In most cases, a window is associated with the shell. 

Term
Command
Definition

Often called a statement, instructs the intpreter to do something.

 

 

example: The statement print 'Yankees rule!' instructs the interpreter to output the string Yankees rule! to the window associated with the shell. 

Term
Objects
Definition

 

The core things that Python programs manipulate.

Every object has a Type that defines the kinds of things that programs can do with objects of that type. 

Term
Type
Definition

 

defines the kinds of things that programs can do with objects of that type. 

 

Types are either scalar or non-scalar. 

Term
Scalar
Definition

 

objects that are indivisible. Think of them as the atoms of the language. Non-scalar objects, for example strings, have internal structure. 

There are four types of Scalar Objects:

int, float, bool, none

Term
Expressions 
Definition

Operators and Objects can be combined to form expressions.

Every expression evaluates to an object of some Type referred to as the Value of the expression.

Term
Value
Definition
an expression evaluated to an object of some Type.
Term

 

== operator 

Definition

 

used to test whether two expressions evaluate to the same value.

Term

 

!= operator 

Definition

 

used to test whether two expressions evaluate to different values. 

Term

 

symbol >>>  

Definition

 

is a shell prompt indicating that the interpreter is expecting the user to type some Python code into the shell. 

Term
i+j 
Definition
the sum of and j. If and j are both of type int,the result is an int. If either of them is a float, the result is a float. 
Term

i–j 

Definition
I minus j. If I and j are both of type int, the result is an int. If either of them is a float, the result is a float. 
Term

i*j 

Definition
 the product of I and j. If I and j are both of type int, the result is an int. If either of them is a float, the result is a float. 
Term

 

 

i//j 

 

Definition

 

 

integer division. For example, the value of 6//2 is the int 3 and the value of 6//4 is the int 1. The value is 1 because integer division returns the quotient and ignores the remainder. 

 

Term

 

 

i/j 

 

Definition

 

 

i divided by j. In Python 2.7, when i and j are both of type int, the result is also an int, otherwise the result is a float. In this book, we will never use / to divide one int by another. We will use // to do that. (In Python 3, the / operator, thank goodness, always returns a float. For example, in Python 3 the value of 6/4 is 1.5.) 

 

Term

 

 

i%j 

 

Definition

 

 

he remainder when the int i is divided by the int j. It is typically pronounced “i mod j,” which is short for “i modulo j.” 

 

Term

 

 

i**j 

 

Definition

 

 

I raised to the power j. If I and j are both of type int, the result is an int. If either of them is a float, the result is a float. 

 

Term
Comparison Operators
Definition

 

 

== (equal),

!= (not equal),

> (greater),

>= (at least),

 <, (less)

<= (at most) 

 

Term
Operators of Type Bool
Definition

and, or, not

 

Term
Variable
Definition
in Python, just a name nothing more
Term
Assignment
Definition

A statement associating the variable or name to the left side of = symbol and the object to the right side of the = symbol.

(An object can have one, more than one, or no name associated with it.)

Term
(Python) rules of variable names:
Definition

 

 case-sensitive. Use digits (but they cannot start with a digit), and use the special character _

 

Term
(Python) Reserved Words
Definition

Also called keywords

 

have built-in meanings and cannot be used as variable names. Different versions of Python have slightly different lists of reserved words. The reserved words in Python 2.7 are:

 and, as, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, with, while, and yield. 

Term
Comments
Definition
Enhance the readability of code. (To start a comment use #)
Term
Straight Line Programs
Definition
Execute one statement after another in the order that they appear, and stop when they run out of statements.
Term
Conditional
Definition

The simplest branching statement consisting of three parts

  • a test, i.e., an expression that evaluates to either True or False;
  • A block of code that is executed if the test evaluates to True;
  • an optional block of code that is executed if the test evaluates to False.
Term
Example of Boolean Expression:
Definition

 

  1. Conditional statement where any expression that evaluates to True or False can follow the reserved word if and a block of code indicates that any sequence of Python statements can follow else 

  2.  if x%2 == 0:

  3.         print 'Even'

  4. else:

  5.         print 'Odd'

  6. print 'Done with conditional'

     

  7.  

Term
Indentation
Definition

 

semantically meaningful in Python. For example, if the last statement in the below code were indented it would be part of the block of code associated with the else, rather than with the block of code following the conditional statement.

 if x%2 == 0:

       print 'Even'

else:

       print 'Odd'

print 'Done with conditional' 

Term
Nested
Definition

 

When either the true block or the false block of a conditional contains another conditional

 f x%2 == 0:

       if x%3 == 0:

            print 'Divisible by 2 and 3'

       else:

            print 'Divisible by 2 and not by 3'

elif x%3 == 0:

       print 'Divisible by 3 and not by 2' 

Term
elif
Definition
a boolean conditional statement  that executes if the conditional expression in the if statement resolves to 0 or a FALSE value. (Stands for: else if)
Term

 

Compound Boolean Expressions example:

Definition

 

if x < y and x < z:

     print 'x is least'

elif y < z:
     print 'y is least'

else:
     print 'z is least' 

Supporting users have an ad free experience!