Section 1
.pdf
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
140 - X625
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
1
Uploaded by DeaconCaterpillar4154
1.10 zyLab training: Interleaved input / output
This section has been set as optional by your instructor.
Auto-graded programming assignments have numerous advantages, but have some challenges too. Students commonly
struggle with realizing that example input / output provided in an assignment's speci±cation interleaves input and output,
but the program should only output the output parts
. If a program should double its input, an instructor might provide this
example:
Enter x: 5
x doubled is: 10
Students often incorrectly create a program that outputs the 5. Instead, the program should only output the output parts:
Enter x: x doubled is: 10
The instructor's example is showing both the output of the program, AND the user's input to that program, assuming the
program is developed in an environment where a user is interacting with a program. But the program itself doesn't output
the 5 (or the newline following the 5, which occurs when the user types 5 and presses enter).
Also, if the instructor con±gured the test cases to observe whitespace, then according to the above example, the program
should output a newline after Enter x:
(and possibly after the 10, if the instructor's test case expects that).
The program below incorrectly
echoes the user's input to the output.
1. Try submitting it for grading (click "Submit mode", then "Submit for grading"). Notice that the test cases fail. The ±rst
test case's highlighting indicates that output 3 and newline were not expected. In the second test case, the -5 and
newline were not expected.
2. Remove the code that echoes the user's input back to the output, and submit again. Now the test cases should all
pass.
553398.3976864.qx3zqy7
LAB
ACTIVITY
1.10.1: zyLab training: Interleaved input / output
2 / 2
Run your program as often as you'd like, before submitting
for grading. Below, type any needed input values in the ±rst
box, then click Run program
and observe the program's
output in the second box.
Enter program input (optional)
5
Input (from above)
main.py
(Your program)
Output (shown below)
Program output displayed here
Coding trail of your work
Instructor note:
Reminder: This lab is ungraded.
main.py
Loading latest submission...
Develop mode
Submit mode
Run program
What is this?
Retrieving signature
Feedback?
1
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
C++ programming
It has been observed by management that some faculty member at the university demonstrates a lackadaisical attitude toward work. They seldom go to class yet at the end of each month they receive full salary. Management has decided that GHs 200, 300, 400, and 500 will be deducted from a faculty’s salary if he/she offends once, twice, third time and forth time respectively in a month. This means that if a faculty member offends once in a month GHs 200 will be deducted, if a faculty member offends twice in a month, GHs 500 (i.e. 200+300) will be deducted, if a faculty member offends three times in a month GHs 900 (i.e.200+300+400), will be deducted and if a faculty member offends four times in a month GHs 1,400 (i.e. 200+300+400+500). Assuming all faculty members are on a flat salary rate of GHs 2500.
a. Write a program to request for the names of four faculty members and number times he/she has absented him/herself from class. One of them should have absented him/herself…
arrow_forward
Data Generator
Most application depends on data. In IoT data is collected/generate by sensors. Since, we do not have access to sensors, we will have to generate data via code. The plotting a sufficient number of these data points (500 in this case) should get the following diagram or something very similar:
You will pick a quantity that you would like to simulate (such as temperature, humidity, barometric pressure, customers arriving at a mall, or just with an alternate descriptor) and decide what shape you will emulate.
This will guide you in selecting sensible value base lines for your data values. e.g., If you pick inside temperature then normal range will be 18-21oC.
Design and build a class that will model your sensor reasonably well.
Notice how the peaks do not occur at regular interval, nor are they the same height. Even the squiggles are the same shapes.
You will create a class with a single public member (property) that give you a “random” value in your intended range and…
arrow_forward
BIRZEIT UNIVERSITY
COMP242 – Project# 2
Buying/Selling Shares of Stocks
Buying and selling shares of stocks of listed companies is a typical task to do
among investors. Of course, this would result in a capital gain (or loss) when the
shares are sold. This is computed as the difference between the shares' selling price
and the price was originally paid to buy it.
When an investor has a single share of stock, the process is easy. However,
when (s)he sells multiple shares of stocks, bought over a period of time and possibly
with different prices, the first step is to identify which shares of stocks are to be
sold. There are two accounting principles (protocols) that are followed depends on
the market of stocks: the shares bought last to be sold first, and the other is to sell
the shares that stayed the longest.
You are required to implement a program to calculate the possible capital
gain/loss using these two protocols. This would facilitate the process for investors
to know which market…
arrow_forward
Python tic tac toe. Tic tac toe is a very popular game. Only two players can play at a time. Game Rules Traditionally the first player plays with "X". So you can decide who wants to go with "X" and who wants to go with "O". Only one player can play at a time. If any of the players have filled a square then the other player and the same player cannot override that square. There are only two conditions that may match will be a draw or may win. The player that succeeds in placing three respective marks (X or O) in a horizontal, vertical, or diagonal row wins the game. Winning condition Whoever places three respective marks (X or O) horizontally, vertically, or diagonally will be the winner. Submit your code and screenshots of your code in action. Hints : Have a function that draws the board Have a function that checks position if empty or not Have a function that checks player or won or not expected output:
arrow_forward
Python tic tac toe.
Tic tac toe is a very popular game. Only two players can play at a time.
Game Rules
Traditionally the first player plays with "X". So you can decide who wants to go with "X" and who wants to go with "O".
Only one player can play at a time.
If any of the players have filled a square then the other player and the same player cannot override that square.
There are only two conditions that may match will be a draw or may win.
The player that succeeds in placing three respective marks (X or O) in a horizontal, vertical, or diagonal row wins the game.
Winning condition
Whoever places three respective marks (X or O) horizontally, vertically, or diagonally will be the winner.
Submit your code and screenshots of your code in action.
Hints :
Have a function that draws the board
Have a function that checks position if empty or not
Have a function that checks player or won or not
expected output:
arrow_forward
PLEASE CODE IN PYTHON
The Penny Pitch game is popular in amusement parks. Pennies are tossed onto a board that has certain areas marked with different prizes. For example:
The prizes available on this board are puzzle, game, ball, poster, and doll. At the end of the game, if all of the squares that say BALL are covered by a penny, the player gets the ball. This is also true for the other prizes. The board is made up of 25 squares (5 x 5). Each prize appears on three randomly chosen squares so that 15 squares contain prizes.In Python, create a PennyPitch application that displays a Penny Pitch board (use [ and ] to indicate squares) with prizes randomly placed and then simulates ten pennies being randomly pitched onto the board. After the pennies have been pitched, the application should display a message indicating which prizes have been won, if any.
arrow_forward
4) Roll the dice 2
Make a program that tests the probability of a certain score when rolling x dice. The user should be
able to choose to roll eg 4 dice and test the probability of a selected score eg 11. The program should
then do a number of simulations and answer how big the probability is for the selected score with as
many dice selected. There must be error checks so that you cannot enter incorrect sums, for
example, it is not possible to get the sum 3 if you roll 4 dice.
TarningsKast2
How many dices do you want to throw?
11
Which number do you want the probability for?
The probability the get the number 11 with 4 dices is 7.19%
Calculate
arrow_forward
JAVA Based Prgm
arrow_forward
c programing language
arrow_forward
Design Assignment: Texas Hold 'em poker game
2 to 8 human or computer players
Each player has a name and stack of chips
Computer players have a difficulty setting: easy, medium, hard
Summary of each hand:
Dealer collects ante from appropriate players, shuffles the deck, and deals each player a hand of 2 cards from the deck.
A betting round occurs, followed by dealing 3 shared cards from the deck.
As shared cards are dealt, more betting rounds occur, where each player can fold, check, or raise.
At the end of a round, if more than one player is remaining, players' hands are compared, and the best hand wins the pot of all chips bet so far.
Create the Use Cases for this system
Create a Use Case diagram for this system
arrow_forward
Moon effect. Some people believe that the Moon controls their activities. If the Moon moves from being directly on the opposite side of
Earth from you to being directly overhead, by what percentage does (a) the Moon's gravitational pull on you increase and (b) your
weight (as measured on a scale) decrease? Assume that the Earth-Moon (center-to-center) distance is 3.82 x 10° m, Earth's radius is
6.37 x 106 m, Moon's mass is 7.36 x 1022 kg, and Earth's mass is 5.98 x 1024 kg.
(a) Number
6.89
Units
percent
(b) Number
i
6.8713e-4
Units
percent
arrow_forward
Write in Java please
arrow_forward
Transcribed Image Text
7-a) Danish works as a constructor. Like all constructors, he is also a beer fan. He likes beer so much that has K cups of beer daily. However, having more than K cups doesn't suit him, because the excess beer won't allow him to sleep at night. Danish's working day is divided into N periods. For every period, he knows how many kilobytes of weight he can lift. During each of the periods, Danish can either have or not to have one bottle of beer. If he is having a bottle of beer in some period, the amount of work in this period drops to zero. But he also gets a productivity boost, if he decides to skip beer during a period and the last bottle of beer, he had was no more than D periods ago, the amount of work during such a period is M times the usual.
arrow_forward
Frog Contest
On their way down the river, Jojo and Lili saw two frogs each in position X1and X2. The two frogs are seen jumping happily towards the same direction that is come to Jojo. After watching the two frogs, Jojo and Lili saw that the speed the two frogs are different. The first frog to start jumping from position X1 has a speed of V1, while the second frog that starts to jump from position X2 has a speed of V2. Jojo guess that "YES" both frogs will be in the same position in a certain time T, while Bibiguessing "NO" the two frogs will never be in the same position in timethe. Help Jojo and Lili calculate the frog's movements to determine whether the guess they are right.
Input FormatThe first line of input consists of a series of integers namely X1, V1, X2, V2, T.X1 and V1 are the initial position and jump speed per second of the first frog.X2 and V2 are the starting position and jump speed per second of the second frog.T is the second when the frog jumps.
Output FormatA string…
arrow_forward
Java problem
First-Player Advantage
Pig is a folk jeopardy dice game with simple rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 ("pig") is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decisions:
roll - If the player rolls a
1: the player scores nothing and it becomes the opponent's turn.
2 - 6: the number is added to the player's turn total and the player's turn continues.
hold - The turn total is added to the player's score and it becomes the opponent's turn.
Problem: There is an advantage to going first in Pig, but how big an advantage is it for “hold at 20 or goal” play? We wish to estimate the probability of a first-player win with a hold-at-20-or-goal play policy. Simulate a given number of two-player Pig games where a player rolls until a 1 ("pig") is rolled, or the turn total is greater than or equal to 20, or the…
arrow_forward
Output for Sample Input 1
3+
Copy
arrow_forward
Problem Description:
In the Whimsical Library, each book is enchanted with a magical code to ensure the
protection of knowledge. The validation process for these magical codes involves a
combination of mathematical spells.
The validation process is described as follows:
Take the sum of the digits at odd positions from left to right.
Take the sum of the squared digits at even positions from left to right.
If the absolute difference between the results from step 1 and step 2 is a prime
number, the book code is considered valid; otherwise, it is invalid.
Example 1:
Consider the magical book code 86420137.
Step 1. Take the sum of the digits at odd positions from left to right.
8+4+0+3=15
Step 2. Take the sum of the squared digits at even positions from left to right.
6^2+2^2+1^2+7^2=36+4+1+49 = 90
Step 3. If the absolute difference between the results from step 1 and step 2 is a prime
number.
115-901 = 75 (not a prime number)
Book code 86420137 is invalid.
Example 2:
Now, let's examine the…
arrow_forward
Java - Painting a Wall
arrow_forward
LISP Function help please
A function that generates a random day of the week, then displays a message saying that "Today is ... and tomorrow will be ...".
Then use the built-in function random first to generate a number between 0 and 6 (including). The expression (random) by itself generates a random integer. You can call it with one parameter to return a value within the range from 0 to the value of the parameter-1. For example, (random 10) will return a value between 0 and 9.
Next, use the number generated at the previous step to retrieve the symbol for the day of the week from the list. Use the built-in elt.
Extract the symbol-name of the day first, then apply the built-in function capitalize to it. Use the result in the princ function call, and do the same thing for the next day.
Make the function return true (t) instead of the last thing it evaluates, to avoid seeing the message printed more than once.
arrow_forward
Exercise 3 - User Name Generator
Add a new class to the Lab2 project called UserNameGenerator. This should implement a
program that reads the user's first and last name (separately), then prints a String composed of
the first 4 letters of the user's last name, followed by the first letter of the user's first name,
followed by a random number in the range of 10 to 99 (inclusive). You can assume the first
name is at least one letter long and the last name is at least 4 letters.
arrow_forward
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
anglers have recently gotten back from a fishing excursion. The I-th angler has gotten a fish of weight man-made intelligence.
Anglers will flaunt the fish they got to one another. To do as such, they initially pick a request where they show their fish (every angler shows his fish precisely once, in this way, officially, the request for showing fish is a stage of integers from 1 to n). Then, at that point, they show the fish they discovered by the picked request. At the point when an angler shows his fish, he may either become glad, become dismal, or stay content.
Assume an angler shows a fish of weight x, and the most extreme load of a formerly shown fish is y (y=0 if that angler is quick to show his fish). Then, at that point:
in the event that x≥2y, the angler becomes cheerful;
in the event that 2x≤y, the angler becomes miserable;
in the event that none of these two…
arrow_forward
Java coding platform
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Related Questions
- C++ programming It has been observed by management that some faculty member at the university demonstrates a lackadaisical attitude toward work. They seldom go to class yet at the end of each month they receive full salary. Management has decided that GHs 200, 300, 400, and 500 will be deducted from a faculty’s salary if he/she offends once, twice, third time and forth time respectively in a month. This means that if a faculty member offends once in a month GHs 200 will be deducted, if a faculty member offends twice in a month, GHs 500 (i.e. 200+300) will be deducted, if a faculty member offends three times in a month GHs 900 (i.e.200+300+400), will be deducted and if a faculty member offends four times in a month GHs 1,400 (i.e. 200+300+400+500). Assuming all faculty members are on a flat salary rate of GHs 2500. a. Write a program to request for the names of four faculty members and number times he/she has absented him/herself from class. One of them should have absented him/herself…arrow_forwardData Generator Most application depends on data. In IoT data is collected/generate by sensors. Since, we do not have access to sensors, we will have to generate data via code. The plotting a sufficient number of these data points (500 in this case) should get the following diagram or something very similar: You will pick a quantity that you would like to simulate (such as temperature, humidity, barometric pressure, customers arriving at a mall, or just with an alternate descriptor) and decide what shape you will emulate. This will guide you in selecting sensible value base lines for your data values. e.g., If you pick inside temperature then normal range will be 18-21oC. Design and build a class that will model your sensor reasonably well. Notice how the peaks do not occur at regular interval, nor are they the same height. Even the squiggles are the same shapes. You will create a class with a single public member (property) that give you a “random” value in your intended range and…arrow_forwardBIRZEIT UNIVERSITY COMP242 – Project# 2 Buying/Selling Shares of Stocks Buying and selling shares of stocks of listed companies is a typical task to do among investors. Of course, this would result in a capital gain (or loss) when the shares are sold. This is computed as the difference between the shares' selling price and the price was originally paid to buy it. When an investor has a single share of stock, the process is easy. However, when (s)he sells multiple shares of stocks, bought over a period of time and possibly with different prices, the first step is to identify which shares of stocks are to be sold. There are two accounting principles (protocols) that are followed depends on the market of stocks: the shares bought last to be sold first, and the other is to sell the shares that stayed the longest. You are required to implement a program to calculate the possible capital gain/loss using these two protocols. This would facilitate the process for investors to know which market…arrow_forward
- Python tic tac toe. Tic tac toe is a very popular game. Only two players can play at a time. Game Rules Traditionally the first player plays with "X". So you can decide who wants to go with "X" and who wants to go with "O". Only one player can play at a time. If any of the players have filled a square then the other player and the same player cannot override that square. There are only two conditions that may match will be a draw or may win. The player that succeeds in placing three respective marks (X or O) in a horizontal, vertical, or diagonal row wins the game. Winning condition Whoever places three respective marks (X or O) horizontally, vertically, or diagonally will be the winner. Submit your code and screenshots of your code in action. Hints : Have a function that draws the board Have a function that checks position if empty or not Have a function that checks player or won or not expected output:arrow_forwardPython tic tac toe. Tic tac toe is a very popular game. Only two players can play at a time. Game Rules Traditionally the first player plays with "X". So you can decide who wants to go with "X" and who wants to go with "O". Only one player can play at a time. If any of the players have filled a square then the other player and the same player cannot override that square. There are only two conditions that may match will be a draw or may win. The player that succeeds in placing three respective marks (X or O) in a horizontal, vertical, or diagonal row wins the game. Winning condition Whoever places three respective marks (X or O) horizontally, vertically, or diagonally will be the winner. Submit your code and screenshots of your code in action. Hints : Have a function that draws the board Have a function that checks position if empty or not Have a function that checks player or won or not expected output:arrow_forwardPLEASE CODE IN PYTHON The Penny Pitch game is popular in amusement parks. Pennies are tossed onto a board that has certain areas marked with different prizes. For example: The prizes available on this board are puzzle, game, ball, poster, and doll. At the end of the game, if all of the squares that say BALL are covered by a penny, the player gets the ball. This is also true for the other prizes. The board is made up of 25 squares (5 x 5). Each prize appears on three randomly chosen squares so that 15 squares contain prizes.In Python, create a PennyPitch application that displays a Penny Pitch board (use [ and ] to indicate squares) with prizes randomly placed and then simulates ten pennies being randomly pitched onto the board. After the pennies have been pitched, the application should display a message indicating which prizes have been won, if any.arrow_forward
- 4) Roll the dice 2 Make a program that tests the probability of a certain score when rolling x dice. The user should be able to choose to roll eg 4 dice and test the probability of a selected score eg 11. The program should then do a number of simulations and answer how big the probability is for the selected score with as many dice selected. There must be error checks so that you cannot enter incorrect sums, for example, it is not possible to get the sum 3 if you roll 4 dice. TarningsKast2 How many dices do you want to throw? 11 Which number do you want the probability for? The probability the get the number 11 with 4 dices is 7.19% Calculatearrow_forwardJAVA Based Prgmarrow_forwardc programing languagearrow_forward
- Design Assignment: Texas Hold 'em poker game 2 to 8 human or computer players Each player has a name and stack of chips Computer players have a difficulty setting: easy, medium, hard Summary of each hand: Dealer collects ante from appropriate players, shuffles the deck, and deals each player a hand of 2 cards from the deck. A betting round occurs, followed by dealing 3 shared cards from the deck. As shared cards are dealt, more betting rounds occur, where each player can fold, check, or raise. At the end of a round, if more than one player is remaining, players' hands are compared, and the best hand wins the pot of all chips bet so far. Create the Use Cases for this system Create a Use Case diagram for this systemarrow_forwardMoon effect. Some people believe that the Moon controls their activities. If the Moon moves from being directly on the opposite side of Earth from you to being directly overhead, by what percentage does (a) the Moon's gravitational pull on you increase and (b) your weight (as measured on a scale) decrease? Assume that the Earth-Moon (center-to-center) distance is 3.82 x 10° m, Earth's radius is 6.37 x 106 m, Moon's mass is 7.36 x 1022 kg, and Earth's mass is 5.98 x 1024 kg. (a) Number 6.89 Units percent (b) Number i 6.8713e-4 Units percentarrow_forwardWrite in Java pleasearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning