• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 6 pages
Exam (elaborations)

D335 Introduction to Python Test Quizzes with Answers Verified 100% Correct

Document preview thumbnail
Preview 2 out of 6 pages

D335 Introduction to Python Test Quizzes with Answers Verified 100% Correct

Content preview

D335 Introduction to Python Test Quizzes with
Answers Verified 100% Correct
What is an expression?

Expressions are any code that return a value when it is evaluated by the program; for example,
the code "5 + 6" is an expression that computes a number by adding two values.

A new variable is created by

performing an assignment statement using the = symbol, such as favoritecolor = red

What character denotes comments in Python?

The character '#' denotes comments

For example:

# this is a comment

How do you print text to the screen in Python?

The primary way to print output is to use the built-in function print(). Ex: print('hello world').

What is text enclosed in quotes called?

A string literal.

What is good practice when writing string literals?

Good practice is to use single quotes for shorter strings and double quotes for more
complicated text or text that contains single quotes, like print("Don't eat that!").

How can output with the print() function be moved to a new line?

Output can be moved to the next line by including "\n" in your string, which is known as

a newline character.

Ex: print('1\n2\n3')

, This will print "1" on the first line, "2" on the second line, and "3" on the third line of output.

"\n" consists of two characters, \ and n, but together are considered by the Python
interpreter as a single character.

What function does Python use to read input from a user?

Reading input is achieved using the input() function.

Does print() automatically add a new line character after it outputs a string?

Yes / True


print() always adds a newline character after the output and automatically moves the
next output to the next row.

How do you keep a print() function from creating a new line?

Use end=' ' inside of the print() function after your string (separated by a comma).

e.g:

print('My name is...', end=' ')

print('Carl?')

What is a SyntaxError?

The program contains invalid code that cannot be understood.

What is a IndentationError?

The lines of the program are not properly indented.

What is a ValueError?

An invalid value is used.
This can occur if giving letters to int().

What is a NameError?

Document information

Uploaded on
March 12, 2025
Number of pages
6
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$12.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
QUINTER
3.6
(73)
Sold
420
Followers
105
Items
39867
Last sold
3 weeks ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions