100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

WGU D335 Into to Python PA|Latest 2025 Update with complete solution

Rating
-
Sold
-
Pages
22
Grade
A+
Uploaded on
13-12-2024
Written in
2024/2025

WGU D335 Into to Python PA|Latest Update with complete solution

Institution
Module










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Module

Document information

Uploaded on
December 13, 2024
Number of pages
22
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

20.01 Practice Lab 1 (Introduction to Java)

INSTRUCTIONS:
Write a program that outputs the pattern shown below, ending with a newline. Each line of the pattern
contains 5 characters including whitespace.

OUTPUT:
H H
H H
HHHHH
H H
H H

SOLUTION (in red):

public class Lab {
public static void main(String[] args) {
/* Type your code here. */
System.out.println("H H");
System.out.println("H H");
System.out.println("HHHHH");
System.out.println("H H");
System.out.println("H H");
}
}

WALKTHROUGH:
Just pay attention to how many characters are required on each line and use System.println();

________________________________
20.02 Practice Lab 2 (Multiplication)

INSTRUCTIONS:
For this lab you will use unit testing to check a null setting using assertions. Use the commented template
code provided to do the following:

Write a program that collects two integer inputs and assigns them to the variables starting_num and
multiplier. Multiply starting_num by multiplier and output the result. Repeat this process two more times,
each time multiplying the previous result by multiplier. The three product outputs should be separated by
a whitespace character, ending with a newline.

If the input is:
25
the output when starting_num = 2 is:
10 50 250

,SOLUTION (in red):

import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
/* Type your code here. */

int num1 = scnr.nextInt();
int num2 = scnr.nextInt();

int starting_num = num1;
int multiplier = num2;

int result1 = starting_num * multiplier;
int result2 = result1 * multiplier;
int result3 = result2 * multiplier;
System.out.println(result1 + " " + result2 + " " + result3);
}
}

OR

int starting_num = scnr.nextInt();
int multiplier = scnr.nextInt();

for (int i = 0; i < 3; i++) {
result *= multiplier;
System.out.print(result);

if (i < 2) {
System.out.print(“ “);
}
}
System.out.println();

________________________________
20.03 Practice Lab 3 (Wedding Tables)
INSTRUCTIONS:
Write a program that calculates the number of full tables for a wedding event, based on the number of
expected guests. Each full table will seat 10 wedding guests.

Collect one integer input and assign it to the variable guests. Using integer division, calculate the total
number of tables that will be filled. The variable tableSize has been declared and initialized and the
variables guests and tablesFilled have been declared in the template code.

, Output the number of tables filled, ending with a newline. Ensure your program output matches the
example formatting below and works for a variety of input values.

If the input is:
340

the output is:
Tables filled: 34

Alternatively, if the input is:
349

the output is:
Tables filled: 34

SOLUTION (in red):

import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int tableSize=10, guests, tablesFilled;
/* Type your code here. */

guests = scnr.nextInt();
tablesFilled = guests / tableSize;
System.out.println("Tables filled: " + tablesFilled);
}
}

________________________________
20.04 Practice Lab 4 (Name / Salary)
INSTRUCTIONS:
Write a program that takes a full name, age, and salary as inputs on separate lines. Output a formatted
message containing the inputs, ending with a newline. Ensure your program output matches the example
formatting below and works for a variety of input values.

If the input is:
Pat Ford
35
60,000

the output is:
Pat Ford is 35 and makes $60,000.
£12.69
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached


Also available in package deal

Get to know the seller

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.
Wiseman NURSING
Follow You need to be logged in order to follow users or courses
Sold
6653
Member since
4 year
Number of followers
3835
Documents
25876
Last sold
3 hours ago
Testsprint

Updated exams .Actual tests 100% verified.ATI,NURSING,PMHNP,TNCC,USMLE,ACLS,WGU AND ALL EXAMS guaranteed success.Here, you will find everything you need in NURSING EXAMS AND TESTBANKS.Contact us, to fetch it for you in minutes if we do not have it in this shop.BUY WITHOUT DOUBT!!!!Always leave a review after purchasing any document so as to make sure our customers are 100% satisfied. **Ace Your Exams with Confidence!**

3.9

1366 reviews

5
672
4
246
3
210
2
76
1
162

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions