• 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 15 pages
Exam (elaborations)

WGU Python D522

Document preview thumbnail
Preview 2 out of 15 pages

Print(10 9) print(10 == 9) print (10 9) Boolean Print(bool("hello")) print(bool("15")) print(bool(x)) Boolean examples of true Print(bool(false)) print( ) print(0) Boolean examples of false Print(isinstance(x, int)) Determine if an object is of a certain data type Int( ) Casts an integer from an integer literal, float literal, or string literal Float( ) Casts a float from an integer literal, a float literal, or a string literal Str( ) Casts a string from strings, integer literals, or a float literals Print("text") Outputs text to the console Print("text", end=" ") print("more text") Will end with a space and continue on the same line ("text more text") Print("wage", wage) Comma will print both items with a space between them Print(variable) Prints the value of the variable Print("1n2n3") Print using newline characters Print( ) Print a blank line Python Run a script file Random function WGU WGU There is no random function, but there is a random module (import random) For x in "bananas": print(x) Strings are arrays, so this will loop through the characters in "bananas" Variable=input( ) Assign text entered by the user to a variable; input is always a string Variable = int(input) Convert user input into an integer Hourly_wage = int(input("enter hourly wage: ")) Display text prompt (enter hourly wage) to request input from user and convert to integer Print(( )) Display a in console in upper case Print(( )) Display a in console as lower case Print(( )) Remove whitespace at beginning and end Print(ce("h", "j")) Replace a string with another string Print(("b")) Split string at specified character C=a+b print(c) Concatenate (combine) two strings A=(f"my name is john, i am {age}") print(a) F-string; { } is the placeholder/modifier A = 85.8756 b = format(a, ".2f") print(b) Modifier to format the value to 2 decimal places (85.88) Price = 85. b = f"price: ${price:.2f}" print(b) F-string with placeholder for price and modifier to format value to 2 decimal places (price: $85.88) What built-in data type is used when you assign text to your variable? WGU WGU Str x = "hello, world!" x = str("hello, world!") What built-in data type is used when you assign a numeric value to your variable? Int x = 20 x = int(20) float x = 20.5 x = float(20.5) complex x = 1j x = complex(1j) What built-in data type is used when you assign a sequence to your variable? List x = ["apple", "banana", "cherry"] x = list(("apple", "banana", "cherry")) tuple x = ("apple", "banana", "cherry") x = tuple(("apple", "banana", "cherry")) range x = range(6) What is the difference between a list and a tuple? List = collection of values tuple = ordered and unchangeable What built-in data type is used when you assign a mapping to your variable? Dict x = {"name" : "john", "age" : 36} x = dict(name="john", age=36) What built-in data type is used when you assign a set to your variable? Set x = {"apple", "banana", "cherry"} x = set(("apple", "banana", "cherry")) frozenset WGU WGU x = frozenset({"apple", "banana", "cherry"}) x = frozenset(("apple", "banana", "cherry")) What built-in data type is used when you assign a boolean to your variable? Bool x = true x = bool(5) What built-in data type is used when you assign binary to your variable? Bytes x = b"hello" x = bytes(5) bytearray x = bytearray(5) memoryview x = memoryview(bytes(5)) What built-in data type is used when you assign the value none to your variable? Nonetype x = none What is syntax error? Contains invalid code that cannot be understood What is indentation error? Lines of the program are not properly indented What is a value error? Invalid value is used (e.g., int(three)) What is a name error? Program tries to use a variable that does not exist What is a type error? Operation uses incorrect types (e.g. Int(5) + string(four)) How do you check which version of python editor you have? Import sys print(on) How do you edit, save, and run a python file? Edit = can edit in a text editor save = save as run = in command prompt, type Can you run python in the command line? Type python or py you will see python version information and when you are finished, type exit( )

Content preview

WGU



WGU Python D522

Print(10 > 9)
print(10 == 9)
print (10 < 9)
Boolean
Print(bool("hello"))
print(bool("15"))
print(bool(x))
Boolean examples of true
Print(bool(false))
print( )
print(0)
Boolean examples of false
Print(isinstance(x, int))
Determine if an object is of a certain data type
Int( )
Casts an integer from an integer literal, float literal, or string literal
Float( )
Casts a float from an integer literal, a float literal, or a string literal
Str( )
Casts a string from strings, integer literals, or a float literals
Print("text")
Outputs text to the console
Print("text", end=" ")
print("more text")
Will end with a space and continue on the same line ("text more text")
Print("wage", wage)
Comma will print both items with a space between them
Print(variable)
Prints the value of the variable
Print("1\n2\n3")
Print using newline characters
Print( )
Print a blank line
Python file.py
Run a script file
Random function
WGU

, WGU


There is no random function, but there is a random module
(import random)
For x in "bananas":
print(x)
Strings are arrays, so this will loop through the characters in "bananas"
Variable=input( )
Assign text entered by the user to a variable; input is always a string
Variable = int(input)
Convert user input into an integer
Hourly_wage = int(input("enter hourly wage: "))
Display text prompt (enter hourly wage) to request input from user and convert to
integer
Print(a.upper( ))
Display a in console in upper case
Print(a.lower( ))
Display a in console as lower case
Print(a.strip( ))
Remove whitespace at beginning and end
Print(a.replace("h", "j"))
Replace a string with another string
Print(a.split("b"))
Split string at specified character
C=a+b
print(c)
Concatenate (combine) two strings
A=(f"my name is john, i am {age}")
print(a)
F-string; { } is the placeholder/modifier
A = 85.8756
b = format(a, ".2f")
print(b)
Modifier to format the value to 2 decimal places (85.88)
Price = 85.87562649
b = f"price: ${price:.2f}"
print(b)
F-string with placeholder for price and modifier to format value to 2 decimal places
(price: $85.88)
What built-in data type is used when you assign text to your variable?



WGU

Document information

Uploaded on
August 29, 2025
Number of pages
15
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$17.49

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.
AlexScorer
2.5
(2)
Sold
11
Followers
0
Items
1807
Last sold
2 months 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