WGU C949 Data Structures & Algorithms
Chapters 1-4 Exam Questions With Correct
Answers
In |Python, |there |are |three |(3) |different |types |of |commenting |styles. |What |are |they? |- |
CORRECT |ANSWER✔✔-In-line, |Multiline, |Documentation |Strings |(Docstrings)
"Comments |used |to |add |meaning |to |a |program |and |explain |logic |in-line |with |the |code |being |
discussed. |These |comments |are |good |for |quick |explanations |and |are |indicated |by |using |the |# |
character |and |a |space. |if |n |% |2 |== |1: |# |n |is |odd" |- |CORRECT |ANSWER✔✔-In-line
"Comments, |also |known |as |block |comments, |are |good |for |more |in-depth |explanations |or |
when |you |want |to |comment |a |complex |section |of |code. |In |Python |we |append |together |a |
section |of |lines |all |beginning |with |the |# |character |to |achieve |this. |# |This |section |of |code |# |
Requires |a |longer |comment |# |So |we |can |add |as |many |lines |as |needed" |- |CORRECT |
ANSWER✔✔-Multiline
"These |are |used |like |the |comments |referenced |above |but |it |allows |you |much |more |space |to |
write |a |longer |message |and |they |can |be |written |out |at |runtime, |which |means |the |interpreter |
does |see |them, |unlike |other |types |of |comments. |These |should |be |used |to |describe |what |a |
piece |of |code |is |doing |in |detail. |You |enclose |these |types |of |comments |in |three |quote |marks
|"""""". |- |CORRECT |ANSWER✔✔-Document |Strings |(Docstrings)
""""""This |function |checks |to |see |whether |a |number |is |odd |or |even""""""" |- |CORRECT |
ANSWER✔✔-def |odd_function(n)
Consists |of |instructions |that |a |computer |executes |(or |runs), |like |multiplying |numbers |or |
printing |a |number |to |a |screen. |- |CORRECT |ANSWER✔✔-Computer |program
,Means |to |reduce |a |complex |task |into |simpler |basic |steps, |making |the |whole |task |easier |to |
solve. |- |CORRECT |ANSWER✔✔-Task |decomposition
Is |a |methodical |step-by-step |procedure |to |perform |a |task. |- |CORRECT |ANSWER✔✔-Algorithm
The |method |of |evaluating |a |problem's |most |basic |parts |and |then |creating |an |algorithm |to |
solve |that |problem. |- |CORRECT |ANSWER✔✔-Computational |thinking
For |Python, |an |application |that |can |be |used |on |various |operating |systems, |including |Microsoft |
Windows, |Linux, |and |MacOS. |- |CORRECT |ANSWER✔✔-Python |interpreter
A |program |that |allows |the |user |to |execute |one |line |of |code |at |a |time. |- |CORRECT |
ANSWER✔✔-Interactive |interpreter
A |common |word |for |the |textual |representation |of |a |program. |- |CORRECT |ANSWER✔✔-Code |
(Coding)
A |row |of |text. |- |CORRECT |ANSWER✔✔-Line
(">>>") |that |indicates |the |interpreter |is |ready |to |accept |code. |- |CORRECT |ANSWER✔✔-The |
interactive |interpreter |displays |a |prompt(">>>")
Informs |the |programmer |that |the |interpreter |is |ready |to |accept |commands. |- |CORRECT |
ANSWER✔✔-Prompt
A |program |instruction. |- |CORRECT |ANSWER✔✔-statement
,True |or |false. |A |program |mostly |consists |of |a |series |of |statements, |each |statement |usually |
appears |on |its |own |line. |- |CORRECT |ANSWER✔✔-True
Code |that |returns |a |value |when |evaluated; |for |example, |the |code |wage |* |hours |* |weeks |is |an |
expression |that |computes |a |number. |* |is |the |symbol |for |multiplication. |The |names |wage, |
hours, |weeks, |and |salary |are |variables, |which |are |named |references |to |values |stored |by |the |
interpreter. |- |CORRECT |ANSWER✔✔-Expression
A |new |variable |is |created |by |performing |an |___________ |using |the |= |symbol, |such |as |salary |= |
wage |* |hours |* |weeks, |which |creates |a |new |variable |called |salary. |- |CORRECT |ANSWER✔✔-
assignment
Displays |variables |or |expression |values. |- |CORRECT |ANSWER✔✔-print()
#' |characters |denote |____________, |which |are |optional |but |can |be |used |to |explain |portions |of
|code |to |a |human |reader. |- |CORRECT |ANSWER✔✔-comments
The |primary |way |to |print |output |is |to |us |the |built-in |function |_________. |- |CORRECT |
ANSWER✔✔-print()
Text |enclosed |in |quotes |is |known |as |a |... |- |CORRECT |ANSWER✔✔-string |literal
True |or |False. |Text |in |string |literals |may |not |have |letters, |numbers, |spaces, |or |symbols |like |"@"
|or |"#". |- |CORRECT |ANSWER✔✔-False
Multiple |print |statements |will |each |print |on |a |new |output |line. |How |would |you |keep |the |next |
print's |output |on |the |same |line |separated |by |a |single |space? |- |CORRECT |ANSWER✔✔-
print('Hello', |end |= |' |')
, True |or |False. |A |string |literal |can |be |surrounded |by |matching |single |or |double |quotes: |'Python |
rocks!' |or |"Python |rocks!". |Good |practice |is |to |use |single |quotes |for |shorter |strings, |and |
double |quotes |for |more |complicated |text |or |text |that |contains |single |quotes |(such |as |
print("Don't |eat |that!")). |- |CORRECT |ANSWER✔✔-True
Write |code |that |will |print |"Halt!" |and |"No |access!" |on |a |single |line. |- |CORRECT |
ANSWER✔✔-"print('Halt!', |end |= |' |') |print('No |access!')"
Write |code |that |will |print: |Welcome! |- |CORRECT |ANSWER✔✔-print('Welcome!')
Given |the |variable |num_cars |= |9, |write |a |statement |that |prints |9. |- |CORRECT |ANSWER✔✔-
print(num_cars)
"Write |code |that |prints |the |following: |Wage: |20 |Goodbye." |- |CORRECT |ANSWER✔✔-"wage |= |
20 |print('Wage:' |, |wage) |#Comma |separates |multiple |items |print('Goodbye.')"
"Assume |variable |age |= |22 |What |is |the |output |of |print('You |are' |, |age, |'years |old.')" |- |CORRECT
|ANSWER✔✔-You |are |22 |years |old.
A |new |line |can |also |be |output |by |inserting |\n, |known |as |a |______________ |___________, |
within |a |string |literal. |- |CORRECT |ANSWER✔✔-newline |character
Reading |input |is |achieved |using |the |________ |function. |- |CORRECT |ANSWER✔✔-input()
Write |a |statement |that |reads |a |user-entered |string |into |variable |num_cars. |- |CORRECT |
ANSWER✔✔-num_cars |= |input()
Determines |how |a |value |can |behave. |- |CORRECT |ANSWER✔✔-type
Chapters 1-4 Exam Questions With Correct
Answers
In |Python, |there |are |three |(3) |different |types |of |commenting |styles. |What |are |they? |- |
CORRECT |ANSWER✔✔-In-line, |Multiline, |Documentation |Strings |(Docstrings)
"Comments |used |to |add |meaning |to |a |program |and |explain |logic |in-line |with |the |code |being |
discussed. |These |comments |are |good |for |quick |explanations |and |are |indicated |by |using |the |# |
character |and |a |space. |if |n |% |2 |== |1: |# |n |is |odd" |- |CORRECT |ANSWER✔✔-In-line
"Comments, |also |known |as |block |comments, |are |good |for |more |in-depth |explanations |or |
when |you |want |to |comment |a |complex |section |of |code. |In |Python |we |append |together |a |
section |of |lines |all |beginning |with |the |# |character |to |achieve |this. |# |This |section |of |code |# |
Requires |a |longer |comment |# |So |we |can |add |as |many |lines |as |needed" |- |CORRECT |
ANSWER✔✔-Multiline
"These |are |used |like |the |comments |referenced |above |but |it |allows |you |much |more |space |to |
write |a |longer |message |and |they |can |be |written |out |at |runtime, |which |means |the |interpreter |
does |see |them, |unlike |other |types |of |comments. |These |should |be |used |to |describe |what |a |
piece |of |code |is |doing |in |detail. |You |enclose |these |types |of |comments |in |three |quote |marks
|"""""". |- |CORRECT |ANSWER✔✔-Document |Strings |(Docstrings)
""""""This |function |checks |to |see |whether |a |number |is |odd |or |even""""""" |- |CORRECT |
ANSWER✔✔-def |odd_function(n)
Consists |of |instructions |that |a |computer |executes |(or |runs), |like |multiplying |numbers |or |
printing |a |number |to |a |screen. |- |CORRECT |ANSWER✔✔-Computer |program
,Means |to |reduce |a |complex |task |into |simpler |basic |steps, |making |the |whole |task |easier |to |
solve. |- |CORRECT |ANSWER✔✔-Task |decomposition
Is |a |methodical |step-by-step |procedure |to |perform |a |task. |- |CORRECT |ANSWER✔✔-Algorithm
The |method |of |evaluating |a |problem's |most |basic |parts |and |then |creating |an |algorithm |to |
solve |that |problem. |- |CORRECT |ANSWER✔✔-Computational |thinking
For |Python, |an |application |that |can |be |used |on |various |operating |systems, |including |Microsoft |
Windows, |Linux, |and |MacOS. |- |CORRECT |ANSWER✔✔-Python |interpreter
A |program |that |allows |the |user |to |execute |one |line |of |code |at |a |time. |- |CORRECT |
ANSWER✔✔-Interactive |interpreter
A |common |word |for |the |textual |representation |of |a |program. |- |CORRECT |ANSWER✔✔-Code |
(Coding)
A |row |of |text. |- |CORRECT |ANSWER✔✔-Line
(">>>") |that |indicates |the |interpreter |is |ready |to |accept |code. |- |CORRECT |ANSWER✔✔-The |
interactive |interpreter |displays |a |prompt(">>>")
Informs |the |programmer |that |the |interpreter |is |ready |to |accept |commands. |- |CORRECT |
ANSWER✔✔-Prompt
A |program |instruction. |- |CORRECT |ANSWER✔✔-statement
,True |or |false. |A |program |mostly |consists |of |a |series |of |statements, |each |statement |usually |
appears |on |its |own |line. |- |CORRECT |ANSWER✔✔-True
Code |that |returns |a |value |when |evaluated; |for |example, |the |code |wage |* |hours |* |weeks |is |an |
expression |that |computes |a |number. |* |is |the |symbol |for |multiplication. |The |names |wage, |
hours, |weeks, |and |salary |are |variables, |which |are |named |references |to |values |stored |by |the |
interpreter. |- |CORRECT |ANSWER✔✔-Expression
A |new |variable |is |created |by |performing |an |___________ |using |the |= |symbol, |such |as |salary |= |
wage |* |hours |* |weeks, |which |creates |a |new |variable |called |salary. |- |CORRECT |ANSWER✔✔-
assignment
Displays |variables |or |expression |values. |- |CORRECT |ANSWER✔✔-print()
#' |characters |denote |____________, |which |are |optional |but |can |be |used |to |explain |portions |of
|code |to |a |human |reader. |- |CORRECT |ANSWER✔✔-comments
The |primary |way |to |print |output |is |to |us |the |built-in |function |_________. |- |CORRECT |
ANSWER✔✔-print()
Text |enclosed |in |quotes |is |known |as |a |... |- |CORRECT |ANSWER✔✔-string |literal
True |or |False. |Text |in |string |literals |may |not |have |letters, |numbers, |spaces, |or |symbols |like |"@"
|or |"#". |- |CORRECT |ANSWER✔✔-False
Multiple |print |statements |will |each |print |on |a |new |output |line. |How |would |you |keep |the |next |
print's |output |on |the |same |line |separated |by |a |single |space? |- |CORRECT |ANSWER✔✔-
print('Hello', |end |= |' |')
, True |or |False. |A |string |literal |can |be |surrounded |by |matching |single |or |double |quotes: |'Python |
rocks!' |or |"Python |rocks!". |Good |practice |is |to |use |single |quotes |for |shorter |strings, |and |
double |quotes |for |more |complicated |text |or |text |that |contains |single |quotes |(such |as |
print("Don't |eat |that!")). |- |CORRECT |ANSWER✔✔-True
Write |code |that |will |print |"Halt!" |and |"No |access!" |on |a |single |line. |- |CORRECT |
ANSWER✔✔-"print('Halt!', |end |= |' |') |print('No |access!')"
Write |code |that |will |print: |Welcome! |- |CORRECT |ANSWER✔✔-print('Welcome!')
Given |the |variable |num_cars |= |9, |write |a |statement |that |prints |9. |- |CORRECT |ANSWER✔✔-
print(num_cars)
"Write |code |that |prints |the |following: |Wage: |20 |Goodbye." |- |CORRECT |ANSWER✔✔-"wage |= |
20 |print('Wage:' |, |wage) |#Comma |separates |multiple |items |print('Goodbye.')"
"Assume |variable |age |= |22 |What |is |the |output |of |print('You |are' |, |age, |'years |old.')" |- |CORRECT
|ANSWER✔✔-You |are |22 |years |old.
A |new |line |can |also |be |output |by |inserting |\n, |known |as |a |______________ |___________, |
within |a |string |literal. |- |CORRECT |ANSWER✔✔-newline |character
Reading |input |is |achieved |using |the |________ |function. |- |CORRECT |ANSWER✔✔-input()
Write |a |statement |that |reads |a |user-entered |string |into |variable |num_cars. |- |CORRECT |
ANSWER✔✔-num_cars |= |input()
Determines |how |a |value |can |behave. |- |CORRECT |ANSWER✔✔-type