Module 1

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Assume you wanted to perform some mathematical calculation using the variable "x" (such as adding 5 to its value) - which line of code would allow you to do this? A. x = "1000" B. x = "one thousand" C. x = 1000

C. x = 1000

variable naming rule #4

Cannot use any of Python's reserved words to name your variable

Consider the following statement in Python: a = 123 The variable 'a' is storing a: A. A logical value B. A string C. A numeric value

idk

floating point numbers

must have a decimal point in them. Can also be positive or negative; to divide you use / and it will give you the division between 2 numbers and will maintain the floating-point value of that division

variable naming rule #1

variable names cannot contain spaces

variable naming rule #2

you cannot use a number as the first character of a variable

calling a function with multiple arguments

separate your arguments using commas

Consider this statement in Python: print ("One", "Two", "Three") "print" is considered a/n: A. A variable B. String C. The name of a function D. A numeric literal

C. The name of a function

Which symbol is used to delimit strings (select all that apply)? A. """ B. , C. _ D. " E. - F. '

A. """ D. " F. '

The input function accepts ________ as an argument. A. an int B. a String C. nothing D. a float

B. a String

Consider this statement in Python: print ("One", "Two", "Three") "One" is considered a/n: A. The name of a function B. A variable C. A numeric literal D. Argument

D. Argument

Imagine that you have a single line of Python code that reads: print ("Hello, world!") If you wanted to run this statement and immediately see the result you could do so by using __________ mode in IDLE. A. Interactive B. Object-Oriented C. Functional D. Script

A. Interactive

Which of the following could be a proper function call (select all that apply)? A. foo() B. foo("hello there") C. foo - "hello there" D. foo E. foo(4) F. foo(10,"hello there")

A. foo() B. foo("hello there") E. foo(4) F. foo(10,"hello there")

Order the following steps so that if a python interpreter were trying to execute them, the value of x would be printed out as 11 without an error (Select all sequences that would execute correctly): 1. x = y + 5 2. y = 6 3. print(x) 4. x = 0 A. 2,1,4,3 B. 4,2,1,3 C. 4,1,2,3 D. 1,2,3,4 E. 2,1,3,4 F. 2,4,1,3 G. 3,1,2,4

B. 4,2,1,3 F. 2,4,1,3 MISSING ONE

Any sequence of alpha-numeric characters (numbers and letters) can be used as a variable name (i.e. "abc123" and "123abc" are both valid variable names) A. True B. False

False

You would use Python's "Interactive Mode" to write a long program that contains many lines of code. True False

False

string

a sequence of characters enclosed in quotation marks; data that is compromised of text; they can contain 0 or more characters

integers

can be both positive and negative; to divide you use // and will give you the whole number value of that division.

variables

container that temporarily stores info in your computer's memory while the program is running;

Python supports two different division operators True False

True

What kind of information is being stored in the variable x? x = "1005" A. An integer B. A floating point number C. A String

C. A String

Consider the following statement in Python: a = "123" The variable 'a' is storing a: A. A numeric value B. A logical value C. A string

C. A string

The output of print("I'm ready to begin") is: A. Im ready to begin B. "I'm ready to begin" C. I'm ready to begin D. I"m ready to begin E. error

C. I'm ready to begin

Imagine that you have access to a file called "myprogram.py" that contains the following statements: print ("Hello, world!") print ("Welcome to my program!") print ("Thanks for visiting!") If you wanted to run all of these statements in order you could do so by using ______ mode in IDLE. A. Interactive B. Object Oriented C. Script D. Functional

C. Script

Which of the following is a valid variable name? A. my 1st variable B. !my_1st_variable C. my_1st_variable D. 1st_variable

C. my_1st_variable

A "string" is: A. A reusable command that the programmer can "call" to execute a series of statements B. A sequence of numbers that represents numeric information C. A programmatic construct that lets the programmer store information during the execution of a program D. A sequence of characters that represents textual information

D. A sequence of characters that represents textual information

variable naming rule #3

Python variable names are case sensitive

string literal

Text enclosed by double quotes; "hard coded" sequence of characters inside of your program

numeric literal

a numeric value that you hard code into your program; Python supports 2 diff numeric data types: integers and floating point numbers;

function

a pre-written piece of computer code that will perform an action or set of actions must always have an open and closed parenthesis at the end because it will be expecting arguments

input function

input takes one argument and that is the prompt that you want to ask the user; that is the question that you want the user to respond to; always returns a "string"

Interactive mode

issue a command to be immediately executed by Python

order of operations in python

items within parenthesis first multiplication and division at the next level addition and subtraction at the third level

numeric values

not delimited so you do not need to surround them with "


Set pelajaran terkait

Business: Market Segmentation and Target Market

View Set

American Government: America a Unique Nation. Chapter 1. pp. 1-14

View Set

The French Revolution and Napoleon

View Set

Chapter 6: Test Yourself Review Questions

View Set