Intro to Computing

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which string definition results in an error?

'It's 10am'

Which expression evaluates to 20?

(2 + 3) * 4

Which statement is true regarding Python on a Mac?

A Mac comes with a version of Python already installed.

When working with the Terminal inside of VSCode, how can you expand the pane?

Click the up arrow.

Why doesn't a Python file execute when you double-click it?

Double-clicking does not run the Python Interpreter on the source code.

Python treats all numbers the same, regardless of numerical value.

FALSE

Source code is written in rich text.

FALSE

The code that's contained inside of a function is often called the function's legs.

FALSE

Which data type in Python represents a number with a decimal point?

Float

Which is not a benefit of functions?

Functions eliminate crashes in your code.

Which value is not an argument to the "hello" function? def hello(name): print("Hey,", name) hello("John") hello("Mya")

Hey

Which language is considered an interpreted language?

JavaScript

What is the output of the following Python code? first_name = "Jeff" #first_name = "Sara" print(first_name)

Jeff

What is the output of this Python code? first_name = "Jeff" first_Name = "Sara" print(first_name)

Jeff

Which concern could be considered a disadvantage of Python under certain circumstances?

Python is a general-purpose language.

Which command will start the Python prompt on your computer?

python3

What will the following condition print? if (num>=0): print(num) else: print(-1 * num)

the absolute value of num

Why are there many programming languages?

to address many different computing needs

Why does VS Code need a Python interpreter to be specified?

to provide code suggestions

What is the output of the following program? def isEven(num): return num % 2 == 0 if isEven(3): print("3 is even") else: print("3 is not even")

3 is not even

Which expression evaluates to 2?

5 % 3

What will the following code print? number = 3**2 Number = 2**3 print(number)

9

Which of these is not a relational operator?

=

What does the void keyword mean when it is specified before a function definition?

The function does not return a value.

Why is there no output for this program? def goodbye(): print("Bye")

We never called the goodbye function.

If you were developing an application for an iPhone, which IDE would you use?

XCode

Which statement is true regarding Python support in VS Code?

You need to install a VS Code extension to support Python.

In this function definition, the variable "name" is _____. def hello(name): print("Hey,", name)

a parameter

Which tool is used to write source code?

a text editor

Which variable name is valid in Python?

account_balance

Multiple statements grouped together are called a _____.

block

Any expression that breaks down to either true or false is called a conditional, or _____.

boolean expression

What can the following function be used for? def mystery(x): if (x % 2 == 0): return("yes") else: return("no")

checking whether a number is even or odd

You have Python 3 installed. How will you run the Python code in the file "process.py" on the command-line prompt?

python3 process.py

When would a removal of white space be problematic?

removing the space after the "if" in if x==1

Which Python keyword is used to send back values from a function?

return

The code below, which is supposed to print the value of the variable x, is not working. Which category does the error fall under? x = 5 print("x")

semantic

Which variable name is valid in Python?

speed_limit

What will the following code print? variable = "12" print(type(variable))

str

Although Python ignores empty lines, one place where whitespace does make a difference is inside of _____.

strings

Which is an example of a syntax error?

2 (4*2)

Which operator will you use to return true if two variables are different?

!=

Which character starts a comment in Python?

#

Which language does not use a hybrid compiler/interpreter approach?

C++

Given the following code, how would you call the function? def hello(name): print("Hey,", name)

hello("John")

Which of these is NOT a reason why we chose Python as the language for the course?

highly performant

Which code can you use to print if a test score is a pass or a fail?

if (score>=60): print("passed") else: print("failed")

Programming can be defined as: converting ideas into _____ that a computer can understand

instructions

Which data type is a whole number?

int

Which is an example of a runtime error?

name = "It's me!" print("Hello.", Name)

Which if-else statement will not produce this output? is divisible by 3

num = 16 if num % 3 == 0: print("is divisible by 3") else: print("is not divisible by 3")

How would you write the "Hello, world!" program in Python?

print("Hello, world!")

Which of these will not output: I'm learning a lot!

print('I'm learning a lot!')

Which IDE feature allows you to get code suggestions while you are typing?

IntelliSense

What operator do you use to assign a value to a variable?

equals (=)

Which command exits from the Python command-line prompt?

exit()

If you were writing your source code in the JavaScript programming language, what file extension would you use to save your file?

.js

What is the standard extension to use for a Python source code file?

.py

What will the following program print? def mult_inv(num): return 1/num result=mult_inv(3) print(result)

0.333333333

How would you fix the following code to return the remainder of 1,000 divided by 300? 1,000 % 300

1000 % 300

In the Python Terminal, what is printed when running the following line? 5 * 2 + 1

11

If you execute the following expression, what is the output? >>> 3 + 5 * 2

13

What does this expression evaluate to? 3 + 2 * 5

13

What does this expression evaluate to? 2 x 3 + 2 x 5

16

What is the output of the following program? number = 10 if number % 4 == 0: print(number, "is divisible by 4") print("All done")

All done

Given the first line of the function definition below, which programming language is this? def factorial(number)

Ruby

This if-else statement is written in _____. if "apples" == "apples" puts "You're comparing the same thing" end

Ruby

In programming, a crash is when your program stops early or freezes because something unexpected happened.

TRUE

To get Python code suggestions, you need to tell VS Code which Python interpreter to use.

TRUE

With if-else statements, we will always execute one of the code blocks depending on the result of the condition test.

TRUE

Which Mac application allows you to run commands and execute scripts in a command-line interface?

Terminal

What is the issue with the following code? number = input("Enter a number: ") if number == 10: print("The number is greater than 10.") else: print("The number is less than 10.")

The conditional statement is checking for equality.

What is the output of this program? num = 16 if num % 3 == 0: print(num, "is divisible by 3") print("The end")

The end

What is the issue with this function as defined? def double(): print(x*2)

The number to double is not received.

Why do computer instructions need to be sequential?

The order in which these instructions are executed is important.

What will the following code print? def compare(): print(5, "is greater than", 6)

This code will not print anything.

Which keyword does Python use to define a function?

def

Typing "What is 2 plus 2?" into the Python prompt causes a _____.

syntax error


Ensembles d'études connexes

Essentials of Psychiatric Mental Health Nursing Chapters 1-24

View Set

Set12_news, congrats,what about,correct

View Set

PrepU Atraumatic care of children and families

View Set