NUMERICAL METHODS AND ANALYSIS (Long test flash cards format)

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

Guido van Rossum

A Dutch programmer for which he was the "Benevolent Dictator For Life" (BDFL).

Python

A very popular general-purpose interpreted, interactive, object-oriented, and high-level programming language

Variables

Containers for storing data values and it is created the moment you first assign a value to it.

txt.lower()

Convert the value of txt to lower case. txt = "Hello World" txt = _______

txt.upper()

Convert the value of txt to upper case. txt = "Hello World" txt = _______

z = x + y print(z)

Create a variable called z, assign x + y to it, and display the result. x = 5 y = 10 ____ = x + y print(__)

carname = "Volvo"

Create a variable named carname and assign the value Volvo to it.

Floating Point Number

Data type that is a number, positive or negative, containing one or more decimals.

Int or Integer

Data type that is a whole number, positive or negative, without decimals, of unlimited length.

String

Data type that is surrounded by either single quotation marks, or double quotation marks.

Complex Number

Data type that is written with a "j" as the imaginary part.

x = 5 print(x + y)

Display the sum of 5 + 10, using two variables: x and y. _____ = ______ y = 10 print(x __ y)

print(10 / 2) result: 5

Divide 10 by 2, and print the result. print(10__2)

x=txt[0]

Get the first character of the string txt. txt = "Hello World" x = ______

True

If you want to specify the data type of a variable, this can be done with casting.

False

In Camel Case, each word starts with a capital letter.

False

In Pascal Case, each word is separated by an underscore character.

False

In Snake Case, each word, except the first, starts with a capital letter.

global

Insert the correct keyword to make the variable x belong to the global scope. def myfunc(): _______ x x = fantastic

{}

Insert the correct syntax to add a placeholder for the age parameter. age = 36 txt = "My name is John, and I am ____" print(txt.format(age))

x = y = z = "Orange"

Insert the correct syntax to assign the same value to all three variables in one code line. x ____ y ____ z ___ "Orange"

Syntax

It can be executed by writing directly in the Command Line or by creating a python file on the server.

Comments

It can be used to explain Python code, to make the code more readable, and to prevent execution when testing code.

Indentation

It refers to the spaces at the beginning of a code line.

print(10 * 5) result: 50

Multiply 10 with 5, and print the result. print(10 __ 5)

True

Python allows you to assign values to multiple variables in one line.

False

Python allows you to extract the values into variables and this is called packing.

Beginner's Language

Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games.

Interpreted

Python is processed at runtime by the interpreter.

Object-Oriented

Python supports Object-Oriented style or technique of programming that encapsulates code within objects.

myfirst_name="John"

Remove the illegal characters in the variable name. 2my-first_name="John"

True

The Python print() function is often used to output variables.

.py

The file extension for Python programming.

str or string

The following code example would print the data type of x, what data type would that be? x = "Hello World" print(type(x)) _______

tuple

The following code example would print the data type of x, what data type would that be? x = ("apple, "banana", "cherry") print(type(x)) ____________

float

The following code example would print the data type of x, what data type would that be? x = 20.5 print(type(x)) _______

int or integer

The following code example would print the data type of x, what data type would that be? x = 5 print(type(x)) _______

bool

The following code example would print the data type of x, what data type would that be? x = True print(type(x)) _______

list

The following code example would print the data type of x, what data type would that be? x = ["apple, "banana", "cherry"] print(type(x)) ___________

dict

The following code example would print the data type of x, what data type would that be? x = {"name" : "John", "age" : 36} print(type(x) ___________

!=

Use the correct comparison operator to check if 5 is not equal to 10. if 5 ___ 10 print("5 and 10 is not equal")

print(len(x))

Use the len method to print the length of the string. x = "Hello World" print(____________)

True

Variable names are case-sensitive.

Interactive

You can actually sit at a Python prompt and interact with the interpreter directly to write your programs.

False

You can also use the * operator to output multiple variables.

True

You can assign the same value to multiple variables in one line.

#

____ This is a comment

print

______ ("Hello World")

x = 50

create a variable named x and assign the value 50 to it

left side of print

if 5 > 2: print("Five is greater than two!") Insert the missing indentation


Conjuntos de estudio relacionados

Missed questions on quiz (health assessment)

View Set

13.4-13.5, 13.8: Newton's Law of Universal Gravitation, Gravity and Distance: The Inverse-Square Law, & Weight and Weightlessness

View Set

Appendicular Skeleton - bones and bone markings

View Set

HESI & Final: EAQs & Practice Q's (GI Drugs, Laxatives, Vitamins, Glucose Regulation, Insulin, Thyroid/Adrenal & AD Meds, Seizure Meds, Anti-psychotics/Antidepressants Sedatives)

View Set

FP11 3.03 Explain the nature of business plans.

View Set

Set 3 - Florida Life, Health & Annuity Exam Prep by YIS

View Set