Python Essentials Edube Study Set

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

lexis

(a dictionary) a set of words the language offers its users each program has its dictionary

Basic Operators

+ - * / // % **

print(-6//4) print(6.//-4)

-2 -2.0

print(-4 + 4) print(-4. + 8)

0 4.0

What happens if python runs into an invocation like this function_name(argument)

1) checks if the name is legal 2) checks functions requirements for number of arguments allows you to invoke the function in this way 3) leaves the code and jumps into the function you want to invoke 4) executes the code 5) returns to your code andresumes execution

What is the decimal value of the following binary? 1011

11

How to write eleven million one hundred eleven thousand one hundred and eleven in python

11111111 or 11_111_111

example of literal

123 one hundred twenty three

break down 14 % 4

14 // 4 = 3 3 * 4 = 12 14 - 12 = 2

print(0.0000000000000000000001)

1e-22

print(14 % 4)

2

print(6 // 3) print(6 // 3.) print(6. // 3.)

2 2.0 2.0

print("2") print(2)

2- string 2- integer

print(0x123)

291

print(12 % 4.5)

3.0

scientific notation

300000000 = 3 x 10 ^8 in python 3E10 exponent has to be integer base may be integer

print(2+2)

4

print(2 ** 3) print(2 ** 3.) print(2. ** 3) print(2. ** 3.)

8 8.0 8.0 8.0

print(0o123)

83

Who created python?

Guido van Rossum

print("Hello World!")

Hello World!

print("Hello, Python!")

Hello, Python!

python is an example of

High-level programming language

IDLE

Integrated Development and Learning Environment

What is the best definition of a script?

It's a text file that contains instructions which make up a Python program

What is CPython

It's the default, reference implementation of Python, written in the C language

How did python get its name?

Monty Python

how to not divide

NO: division by zero int division by zero find remainder of a division by zero

None literal

NoneType used to represent absence of a value

print("Programming","Essentials","in", sep="***", end="...") print("Python")

Programming***Essentials***in...Python

Select the true statements (two) Python is a good choice for creating and executing tests for applications Python is a good choice for low-level programming Python is free, open-source, and multiplatform Python 3 is backwards compatible with Python 2

Python is a good choice for creating and executing tests for applications Python is free, open-source, and multiplatform

what is CPython?

The default implementation of the Python programming language

What is the expected behavior of the following code? print("Hello!")

The program will output Hello! on the screen

What is machine code

This is low-level programing language consisting of binary digits/bits that the computer can read and understand

print(True > False) print(True < False)

True False

boolean values

True = 1 False = 0

\n meaning

\ is the escape character n is newline

Boolean algebra

a part of algebra which makes use of only two distinct values: true and false, denoted as 1 and 0

source code

a program written in a high-level programming language

semantics

a set of rules determining if a certain phrase makes sense the program has to make sense

syntax

a set of rules used to determine if a certain string of words forms a valid sentence each language has its rules and they must be obeyed

What do you call a file containing a program written in a high level programming language

a source file

debugger

allows you to inspect code step by step

What are the four fundamental elements that make a language

alphabet, lexis, syntax, semantics

Integer division (//)

always gives int result unless one or more float

integer division round

always rounds to nearest int value always goes to lesser int also known as floor division

A complete set of known commands is called:

an instruction list

what do you call a computer program which directly executes instructions written in a program language

an interpreter

keywords

argument (End here) equal sign(=) value (" ")

What can a function do?

cause some effect evaluate a value return it as the function's result

type

characteristic of numeric value which determines its kind range and application

What do you call a command-line interpreter which lets you interact with your OS and execute Python commands and scripts

console

literals

data whose values are determined by the literal itself used to encode data and to put them in your code

end keyword

determines the characters the print() function sends to the output once it reaches the end of its positional arguments. continus at end of sentence, no newline also seen as end="\n"

what is /

division always float

disadvantages of interpretation

don't expect interpretation to ramp up your code to high speed, your code will share the computer's power with the interpreter, so it can't be really fast; both you and the end user have to have the interpreter to run your code.

python goals

easy and intuitive open source understandable suitable for everyday tasks

quote inside string

either escape character 'I\'m happy' open and close string using opposite set of symbols "I'm happy" 'He said "Python" not "typhoon"'

advantages of compilation

execution of translated code is faster only the user has to have the compiler, the end user may use the code without it the translated code is stored using machine language

What is **

exponentiation left is base right is exponent

source file

file containing the source code

What is print?

function name

which is int and which is float 4 4.0

int = 4 float = 4.0

What is python? Compiler or Interpreter?

interpreter

What is true about compilation (two)

it tends to be faster than interpretation The code is converted directly into machine code executable by the processor

what is *

multiplication int rule

what is a string?

must be surrounded by quotes will be taken as data

putting \ in string

must double it or it is an escape \\

Literals

notations for representing some fixed values in code

floating-point (floats)

numbers that contain fractions or decimals

floats

numbers with decimals

Types of literals and examples

numeric 123 string "I am a literal"

integers (int)

numerical numbers without fractions positive or negative

what does print() do?

outputs an empty line

What do functions demand the presence of?

parentheses

octal

preceded by 0o taken from [0..7] range only

hexadecimal

preceded by 0x

want parentheses to appear

print("I like \"Monty Python\"") or print('I like "Monty Python"')

"I'm" ""learning"" """Python""" With newline

print("\"I'm\"\n\"\"learning\"\"\n\"\"\"Python\"\"\"")

"I'm" ""learning"" """Python""" broken up

print(' "I','m" ', sep="'") print(' ""learning"" ') print(' """Python""" ')

python file extension

py

Where can functions come from?

python itself(built-in) python add-ons(modules) write them yourself

Jython

python written in java

What is %

remainder left at int division

Integer rule when both ** are int when at least one ** is float

results in int results in float

sep keyword

separated the outputted arguments with whatever follows sep=""

alphabet

set of symbols used to build words of a certain language must be in recognizable script

What type of literals are the examples? "1.5", 2.0, 528, False

string float int boolean

What type of literals are the examples? "Hello ", "007"

strings

What arguments does print() expect

strings numbers characters logical values objects etc

binary system

system of numbers with 2 as the base made up of 1 and 0 ex 1010 = 10

what is the effect the print() function causes?

takes its arguments converts then into human readable form if needed--not strings sents resulting data to output device

disadvantages of compilation

the compilation itself may be a very time-consuming process, you may not be able to run your code immediately after making an amendment you have to have as many compilers as hardware platforms you want your code to be run on.

what is the expected behavior of the following program? prin("Goodbye!")

the program will generate an error message on the screen

compilation

the source program is translated once (however, this act must be repeated each time you modify the source code) now you can distribute the file worldwide; the program that performs this translation is called a compiler or translator;

console

where you launch newly written code

integers

whole numbers (positive and negative)

editor

will support in writing the code

advantages of interpretation

you can run the code as soon as you complete it, there are no additional phases of translation; the code is stored using programming language, not machine language, this means that it can be run on computers using different machine languages; you don't compile your code separately for each different architecture.

interpretation

you can translate the source program each time it has to run called an interpreter as it has to interpret the code every time it is intended to be executed


Kaugnay na mga set ng pag-aaral

Principles of Macroeconomics Test 2

View Set

Vocabulary Workshop Level E Unit 10 - Completing Sentences

View Set

NC Drivers Ed Practice Written Exam

View Set

2.8 Vocab: Same Side Interior Angles and Same Side Exterior Angles Theorems

View Set

Chapter 23: Nursing Care of the Child With an Alteration in Tissue Integrity/Integumentary Disorder

View Set

MGMT 471 In-Class Quiz Questions

View Set

Chapter 10 Study Guide- US History

View Set