Intro to Programming - Quiz 1

Ace your homework & exams now with Quizwiz!

Python scripts (files) have names that end with what type of file extension?

.py

What is the output of the following code? Print(7%3)

1

What is the value of the expression 1+2**2*3?

13

What is the output of the following code? Print(7//3)

2

What is the output of the following code? Print(100/50)

2.0

What will the following program print out: >>>x=15, >>>x=x+5, >>>print(x)?

20

What will be the value of x after the following statement executes: x=1+2*3-8/4

5.0

What is the output of the following code? k=10 k-=2 print(k)

8

What is the output of the following code? Print(3**2)

9

What will be the value of x when the following statement is executed: x=int(98.6)

98

The python interpreter was written in the ____ programming language.

C

The + operator works with strings, but it is not addition in the mathematical sense. This is called _____.

Concatenation

T/F: A character in a string has an index specifying its position, starting at 1.

False

T/F: Conditional code is when the code block executes from top to bottom.

False

T/F: In Python, a variable must be declared before it is assigned a value.

False

T/F: Programs that are compiled are easier to debug.

False

T/F: Python and C# are both compliers.

False

T/F: Python is a strongly typed language in which you must declare your variables before use.

False

T/F: Spaces are allowed in variable names, but underscores can not be used to separate words in variable names.

False

T/F: Strings are mutable (they can be changed or altered).

False

T/F: The variables Message and message are the same in Python.

False

T/F: Variable names can be arbitrarily long. They can contain both letters and numbers and can begin with a number.

False

T/F: Sequential code is when questions are asked of the program to determine flow.

Flase

Which of the following variables is the "most mnemonic"?

Hours

Python provides a built-in function called ____ that gets input from the keyboard.

Input()

Which of one of the following functions is concerned with getting information from the user?

Input()

An ____ reads the source code of the program as written by the programmer, parses the source code, and interprets the instructions on the fly.

Interpreter

A ____ is an action that Python can perform on a piece of data.

Method

Which of the following elements of a mathematical expression in Python is evaluated first?

Multiplication

A compiler will process the source code and generate a(n) ____ file.

Object

A _____ is a series of characters.

String

The _____ will remove whitespace from both ends of a string and returns a copy of the new string.

Strip() string method

When the computer does not understand the statement you entered, it is a _____ error.

Syntax

____ errors occur when Python doesn't recognize a section of your program as valid Python code.

Syntax

T/F: A program is a sequence of stored instructions.

True

T/F: A sequence of instructions in a programming language is called an Algorithm.

True

T/F: Avoid using Python keywords and function names as variable names.

True

T/F: Every method is followed by a set of parentheses, because methods often need additional information to do their work.

True

T/F: In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type.

True

T/F: Repeative code is when the code block executes over and over until it is finished.

True

T/F: Variable names can contain an underscore _ and can start with one. a. TRUE

True

T/F: Variable names should be short but descriptive.

True

T/F: When you are typing code directly at the chevron >>> you are coding interactively.

True

The ____ function test to see what type an object is and returns true or false.

Type()

Variable names can contain only letters, numbers, and _____.

Underscore

Every ____ is connected to a ____, which is the information associated with it.

Variable, Value

In the following code, x=42. What is "x"?

Varible

Assume the variable x has been initialized to an integer value (e.g., x=3). What does the following statement do? x=x+2

add 3 and 2

Which of these words are reserved words in Python ? a. If b. break c. print d. BOTH A and B

d. BOTH A and B


Related study sets

Simulation Lab 11.1: Module 11 Harden PC with Group Policy Editor

View Set

ECO-102; Ch:14 Oligopoly Study Guide

View Set

Module 3: Chapter 1: Understanding Number Systems and Operations

View Set

Complete Unit Circle 6 Trig Functions

View Set

HEMATOPOIESIS AND ERYTHROPOIESIS Chapters 3 and 4

View Set