Python Crash Course Definitions Module 1 & 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

To define a multiline comment in Python we use the same syntax as that of to define a multiline string. What is that? Triple quotes.

' ' ' This is first line. This is second line. ' ' '

what character is used to define a single line comment?

#

--- ---- ---- - Programming language that is compatible with one or more platforms / operating systems (e.g., Windows, Linux, Mac, iOS, Android).

Cross-platform language

x // y

Floor division operator returns the integer part of the integer division of x by y

--- is a very special data type in Python used to indicate that things are empty or that they return nothing.

None

---- refers to the intended meaning or effect of statements, or collections of words, in both human and computer languages. Semantic errors are also referred to as logical errors.

Semantics

x**2

Square expression returns x squared

x**(1/2)

Square root (½) or (0.5) fractional exponent operator returns the square root of x

a < b

a is smaller than b

if you want to print a message for user input

n = int(input("Enter the number n: "))

---- are names that we give to certain values in our programs.

Variables

---- are used to temporarily store changeable values in programming code.

Variables

--- ---- - a process to restructure code without changing functionality

refactoring code

Python comparison operators return Boolean results (True or False) with strings 1. "a" == "a" 2. "a" != "b" 3. "a" > "b" 4. "a" >= "b" 5. "a" < "b" 6. "a" <= "b"

1. If string "a" is identical to string "a", returns True. Else, returns False 2. If string "a" is not identical to string "b" 3. If string "a" has a larger Unicode value than string "b" 4. If the Unicode value for string "a" is greater than or equal to the Unicode value of string "b" 5. If string "a" has a smaller Unicode value than string "b" 6. If the Unicode value for string "a" is smaller than or equal to the Unicode value of string "b"

---- represent one of two possible states, either true or false.

Booleans

--- --- ---- ---, like JavaScript, are used mostly for web programming. The scripts are transferred from a web server to the end-user's internet browser, then executed in the browser.

Client-side scripting languages

x**3

Cube expression returns x cubed

---- are pieces of code that perform a unit of work

Functions

--- is information that is provided to a program by the end user. Input can be text, voice, images, biometrics, and more.

Input

----- are reserved words that are used to construct instructions

Keywords

--- is the end result of a task performed by a function or computer program. Output can include a single value, a report, entries into a database, and more.

Output

Python Logical Operators Used w/ Comparison Operators a == a and a != b a > b or a <= c not a == b

True if both sides are True, otherwise False. True if either side is True. False if both sides are False. True if the statement is False, False if the statement is True.

you can use comparison operators with the data types int (integers, whole numbers) and float (number with a decimal point or fractional value). Comparison operators return Boolean results. As you learned previously, Boolean is a data type that can hold only one of two values: ---- or -----

True or False

The process of storing a value inside a variable is called ----

assignment.

--- - a combination of numbers, symbols, or other values that produce a result when evaluated

expression

An --- is a combination of numbers, symbols or other variables that produce a result when evaluated.

expression

In Python, text in between quotes -- either single or double quotes -- is a --- --- ---.

string data type

---- is a set of rules for how statements are constructed in both human and computer languages. Programming syntax includes rules for the order of elements in programming instructions, as well as the use of special characters and their placements in statements. This concept is similar to the syntax rules for grammar and punctuation in human language.

syntax

The body of the if block will only execute when the condition evaluates to ---; otherwise, it skipped.

true

You can always check the data type of something using the --- ---.

type() function

--- - an instance of a data type class, represented by a unique name within the code, that stores changeable values of the specific data type

variable

---- ---- is a step-by-step list of instructions that a computer follows to reach an intended goal. It is important to be clear and precise about the actions a computer program is supposed to perform because computers will do exactly what they are instructed to do. Computer programs can be long, complex, and accomplish a variety of tasks. They are often developed by computer programmers and software engineers, but anyone can learn to create them. Computer programs may involve a structured development cycle. They can be written in a wide variety of programming languages, such as Python, Java, C++, R, and more. The completed format of a program is often a single executable file.

Computer program

x**e

Exponent ** operator returns the result of raising x to the power of e

--- --- is the lowest-level computer language. It communicates directly with computing machines in binary code (ones and zeros). In binary code, one equals a pulse of electricity and zero equals no electrical pulse. Machine language instructions are made from translating languages like Python into complex patterns of ones and zeros.

Machine language

x % y

Modulo operator returns the remainder part of the integer division of x by y

------- Platform-specific scripting languages, like PowerShell (for Windows) and Bash (for Linux), are used by system administrators on those platforms.

Platform-specific / OS specific scripting language

--- ---- is a set of written computer instructions, guided by rules, using a computer programming language. It might help to think of the computer instructions as a detailed, step-by-step recipe for performing tasks. The instructions tell computers and machines how to perform an action. Programming code may also be referred to as source code or scripts.

Programming code

---- ----- are similar to human spoken languages in that they both use syntax and semantics. Programming languages are used to write computer programs. Some common programming languages include Python, Java, C, C++, C#, and R.

Programming languages

--- ---- - An interpreter is the program that reads and executes Python code by translating Python code into computer instructions.

Python interpreter

---- are usually shorter and less complex than computer programs. Scripts are often used to automate specific tasks. However, they can be used for complex tasks if needed. Scripts are often written by IT professionals, but anyone can learn to write scripts. Scripts have a shorter, less structured development cycle as compared to the development of complex computer programs and software. Scripts can be written in a variety of programming languages, like Python, Javascript, Ruby, Bash, and more. Some scripting languages are interpreted languages and are only compatible with certain platforms.

Scripts

--- --- --- is written in a way that's readable and doesn't conceal its intent.

Self-documenting code

a <= b

a is smaller than or equal to b

Return Values Using Functions

We may want a function to manipulate data we passed it and then return the result to us. This is where the concept of return values comes in handy. We use the return keyword in a function, which tells the function to pass data back. When we call the function, we can store the returned value in a variable. Return values allow our functions to be more flexible and powerful, so they can be reused and called multiple times.

a == b

a is equal to b

a > b

a is larger than b

a >= b

a is larger than or equal to b

a != b

a is not equal to b

The interpreter --- converts one data type into another.

automatically

----- is the process of replacing a manual step with one that happens automatically

automation

print("") # Prints a --- ----

blank line

The ability of a program to alter its execution sequence is called ----, and it's a key component in making your scripts useful.

branching

A ---- is a reusable block of code that performs a specific task.

function

--- --- - classes of data (e.g., string, int, float, Boolean, etc.), which include the properties and behaviors of instances of the data type (variables)

data types

The purpose of the - keyword is to define a new function. Best practices for writing code that is readable and reusable: Create a reusable function - Replace duplicate code with one reusable function to make the code easier to read and repurpose. Refactor code - Update code so that it is self-documenting and the intent of the code is clear. Add comments - Adding comments is part of creating self-documenting code. Using comments allows you to leave notes to yourself and/or other programmers to make the purpose of the code clear.

def()

---- ---- - when code is written to manually convert one data type to another using a data type conversion function: - - converts a value (often numeric) to a string data type - - converts a value (usually a float) to an integer data type - - converts a value (usually an integer) to a float data type

explicit conversion str() int() float()

a --- is a real number that can contain a fractional part.

float

when the Python interpreter automatically converts one data type to another

implicit conversion

An ---- is a whole number, without a fraction

integer

Variable names must start with a ---- or ----

letter; underscore

list is a data type Example: x = [2, 4, 6, 8] print(type(x)) #Output : ---

list

In ---- --- ---- ---, most coding elements are considered to be objects with configurable properties. For example, a form field is an object that can be configured to accept only dates as input in the mm/dd/yy format, and can be configured to read from and write to a specific database.

object-oriented programming languages

--- --- - a value passed into a function for use within the function

parameter (argument)

We start a function definition with the def keyword, followed by the name we want to give our function. After the name, we have the ---, also called arguments, for the function enclosed in parentheses. A function can have no parameters, or it can have multiple parameters. Parameters allow us to call a function and pass it data, with the data being available inside the function as variables with the same name as the parameters. Lastly, we put a colon at the end of the line. After the colon, the function body starts. It's important to note that in Python the function body is delimited by indentation. This means that all code indented to the right following a function definition is part of the function body. The first line that's no longer indented is the boundary of the function body. It's up to you how many spaces you use when indenting -- just make sure to be consistent.

parameters

--- --- - the value or variable returned as the end result of a function

return value

What does the len() function do?

returns the length of an object or number of characters in a string


Conjuntos de estudio relacionados

Chapter 40 Gastric / Duodenal Disorders Prep U

View Set

Physics 2 final (test 1 material)

View Set

chapter 40: Legal Issues, Quality Assurance, and Infection Prevention

View Set

Ch 14: Cranial Nerves - Name, Roman Numeral, Function

View Set

NRSG 2200 - Exam #5 - Units #9 and #10

View Set