Docsity

Introduction to Python Programming: Basics, Data Types, and Functions | Objective Assessme, Exams of Business Administration

Toggle sidebar
bg1
A+
Introduction to Python Programming:
Basics, Data Types, and Functions |
Objective Assessment | Questions and
Answers with Verified Solutions | Latest
Update
Question:
What are the two main types of flow structures in Python?
Answer:
Conditional flow and repetition flow.
Question:
What is the goal of learning more Python basics in this course?
Answer:
To describe how conditional flow and repetition flow structures are
implemented in Python and to create user-defined functions.
Question:
What is the due date for Homework #2?
Answer:
Next Friday at 9:00 am ET.
Question:
What should you refer to for Python programming formatting requirements?
Answer:
The code standard posted in the module Course Documents > Assignment
Standards.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Introduction to Python Programming: Basics, Data Types, and Functions | Objective Assessme and more Exams Business Administration in PDF only on Docsity!

A+

Introduction to Python Programming:

Basics, Data Types, and Functions |

Objective Assessment | Questions and

Answers with Verified Solutions | Latest

Update

Question:

What are the two main types of flow structures in Python?

Answer:

Conditional flow and repetition flow.

Question:

What is the goal of learning more Python basics in this course?

Answer:

To describe how conditional flow and repetition flow structures are implemented in Python and to create user-defined functions.

Question:

What is the due date for Homework #2?

Answer:

Next Friday at 9:00 am ET.

Question:

What should you refer to for Python programming formatting requirements?

Answer:

The code standard posted in the module Course Documents > Assignment Standards.

What is the purpose of the individualHeader.py file provided?

Answer:

It serves as a template for all class assignments.

Question:

What is required alongside writing Python programs for assignments?

Answer:

Creating flowcharts of the algorithms used.

Question:

What are the two types of loops in Python?

Answer:

For loops and while loops.

Question:

When would you typically use a for loop?

Answer:

When you know exactly how many items you are dealing with or how many times a process must be repeated.

Question:

What is a while loop? A loop that operates until its conditional statement

Answer:

becomes False.

Question:

What is an infinite loop? A loop in which the condition never changes and thus

Answer:

never stops repeating.

What does the expression 'range(3)' return?

Answer:

[0, 1, 2].

Question:

What does 'range(2, 7)' produce? [2, 3, 4, 5, 6].

Question:

What does 'range(1, 7, 2)' generate? [1, 3, 5].

Question:

What does 'range(5, 0, -1)' return? [5, 4, 3, 2, 1].

Question:

What is a key difference between for loops and while loops?

Answer:

For loops iterate over a set of values, while while loops continue until a condition is false.

Question:

What is a common error when using while loops?

Answer:

Creating an infinite loop.

Question:

What should you do to confirm that a Python program works after writing it?

Answer:

Run the file in Spyder.

What does a condition in a list comprehension determine?

Answer:

It evaluates whether to include an expression's result in the new list based on a specified condition.

Question:

What is the general syntax of a while loop?

Answer:

while :

Question:

What is the primary difference between while loops and if statements?

Answer:

While loops can repeat their block of code multiple times, while if statements execute their block only once.

Question:

What is a user-defined function in Python?

Answer:

A function created by the user to perform specific tasks based on input values.

Question:

What are the benefits of using user- defined functions?

Answer:

They provide code modularity, extensibility, and control over input/output formats.

Question:

What does the return statement do in a user-defined function?

Answer:

It outputs a value back to the main code from the function.

What is a flowchart symbol for a user- defined function?

Answer:

It uses the subfunction name with arguments in place of the Start oval.

Question:

What is the significance of the expression 'return xValue, yList'?

Answer:

It allows a function to return multiple values, including a list.

Question:

What is the output of the while loop example that prints every other number from 2 to 20?

Answer:

It outputs the even numbers in that range based on the implemented algorithm.

Question:

What is the role of the 'import math' statement in the while loop example?

Answer:

It imports the math module to use mathematical functions like tan.

Question:

What does the statement 'angle = angle + 0.1' do in the while loop?

Answer:

It increments the angle by 0.1 radians in each iteration of the loop.

Question:

What is the purpose of using range(2,7) in the list comprehension example?

Answer:

It generates a sequence of numbers from 2 to 6 for evaluation in the comprehension.

What is a common practice when writing user-defined functions?

Answer:

To write them in the same file as the main code or in a separate file in the same folder.

Question:

What is the output of the command 'List1 = [x+4 for x in mySet if x > 5]' with mySet = [10,2,8]?

Answer:

List1 will be [14, 12] because only 10 and 8 satisfy the condition.

Question:

What does the term 'code modularity' refer to in the context of functions?

Answer:

It refers to the ability to write a computational process once and reuse it in multiple locations.

Question:

What is Spyder? Spyder is an Integrated Development Environment

Answer:

(IDE) for Python programming.

Question:

What are the major components of the Spyder IDE?

Answer:

The major components include the console, script editor, variable explorer, and file explorer.

What does the variable explorer in Spyder do?

Answer:

The variable explorer allows users to see the values of variables used in the most recently run file, aiding in debugging.

Question:

What is the purpose of the math.py module in Python?

Answer:

The math.py module contains definitions of common mathematical functions and constants that need to be imported before use.

Question:

What is a built-in function in Python? Built-in functions are Python commands that are

Answer:

automatically loaded into the interpreter, such as print() and input().

Question:

What are the three methods for importing modules in Python?

Answer:

  1. import, 2. import as, 3. from import.

Question:

What does the 'import as' method do? It allows you to use a shorter name to refer to the

Answer:

contents of a module in your code.

What is the significance of data types in programming?

Answer:

Data types define how a computer interprets binary numbers and what meaning to attach to them.

Question:

What is the difference between counts and measurements in data types?

Answer:

Counts refer to whole numbers (e.g., 3 students), while measurements can include decimal values (e.g., 4.5 lbs).

Question:

What is the purpose of the 'File Explorer' in Spyder?

Answer:

The File Explorer allows access to files on the hard drive and helps organize Python files.

Question:

What is the benefit of using an IDE like Spyder?

Answer:

An IDE collects all programming tools into a single environment for easier access and management.

Question:

What happens when you click the green arrow in the file editor?

Answer:

Clicking the green arrow saves changes and runs the current file.

What is the purpose of the 'HCRC Callout' announcement?

Answer:

To invite students to join the Honors College Grand Prix team and learn technical skills.

Question:

What is the focus of the 'AMP Callout' announcement?

Answer:

To recruit students interested in driverless racing and autonomous motorsports.

Question:

What is a key feature of the Spyder IDE for editing files?

Answer:

It provides basic text editing functionality along with syntax highlighting and auto-completion.

Question:

What should students do to prepare for Homework #1?

Answer:

Read the instructions in the Homework module on Brightspace and format the assignment accordingly.

Question:

What is the significance of the 'Design Challenge 1' deliverable?

Answer:

It is an individual submission due to Gradescope, emphasizing the importance of personal accountability.

Question:

What does the value 00110100 represent as an integer?

Answer:

The number 52

What does the value 00110100 represent as a string?

Answer:

The character '4'

Question:

What are the four common data types in Python?

Answer:

Integers, Floats, Strings, Booleans

Question:

What is the data type of the value 2.0? Float

Question:

What is the data type of the value 'abc'?

Answer:

String

Question:

What is a collection data type in Python?

Answer:

A grouping of numbers and strings with meaning beyond individual values

Question:

Name three commonly used collection data types in Python.

Answer:

Lists, Tuples, Dictionaries

Question:

What command is used to determine the data type of a value in Python?

Answer:

type()

What are the rules for naming variables in Python?

Answer:

Can contain alphanumeric characters and underscores; cannot start with a number; case- sensitive

Question:

What is casting in Python? Converting a variable from one data type to another

Answer:

using functions like int(), float(), and str()

Question:

What will the command B = int(A) do if A is a float?

Answer:

B will be the truncated value of A

Question:

How can you convert user input to a float in Python?

Answer:

Use R = float(input('What is the radius'))