Questions
Fill in needed code to finish Mastermind program in Python 3.7 syntax Plays the game of...

Fill in needed code to finish Mastermind program in Python 3.7 syntax

Plays the game of Mastermind.
The computer chooses 4 colored pegs (the code) from the colors
Red, Green, Blue, Yellow, Turquoise, Magenta.
There can be more than one of each color, and order is important.

The player guesses a series of 4 colors (the guess).

The computer compares the guess to the code, and tells the player how
many colors in the guess are correct, and how many are in the correct
place in the code. The hint is printed as a 4-character string, where
* means correct color in correct place
o means correct color in incorrect place
- fills out remaining places to make 4

The player is allowed to make 12 guesses. If the player guesses the colors
in the correct order before all 12 guesses are used, the player wins.

'''

import random


def genCode(items, num):
'''
Generates a random code (a string of num characters)
from the characters available in the string of possible items.
Characters can be repeated

items - a string of the possible items for the code
num - the number of characters in the code
returns the code string
'''
# write function body here

def valid(guess, items, num):
'''
Checks a guess string to see that it is the correct length and composed
of valid characters.

guess - a string representing the guess
items - a string of the possible items for the code
num - the number of characters in the code
returns True if the guess is valid, False otherwise
'''
# write function body here

def getGuess(items, num):
'''
Gets a guess string from the user. If the guess is not valid length and
characters, keeps asking until the guess is valid.

items - a string of the possible items for the code
num - the number of characters in the code
returns the valid guess
'''
# write function body here

def matched(code, guess):
'''
Checks to see that the code and the guess match.

code - the string with the secret code
guess - the string with the player's guess
returns True if they match, False otherwise
'''
# write function body here

def genHint(code, guess, items, num):
'''
Generates a string representing the hint to the user.
Tells the player how many colors in the guess are correct,
and how many are in the correct place in the code.
The hint is printed as a num-character string, where
* means correct color in correct place
o means correct color in incorrect place
- fills out remaining places to make num

code - the string with the secret code
guess - the string with the player's guess
items - a string of the possible items for the code
num - the number of characters in the code/hint
returns the valid hint as a string
'''
# write function body here

# Main program starts here

# colors for the code
colors = 'RGBYTM'
# length of the code
num = 4
# maximum number of guesses allowed
maxGuesses = 12

print('Plays the game of Mastermind.')
print()
print('The computer chooses', num, 'colored pegs (the code) from the colors')
print(colors)
print('There can be more than one of each color, and order is important.')
print()
print('The player guesses a series of', num, 'colors (the guess).')
print()
print('The computer compares the guess to the code, and tells the player how')
print('many colors in the guess are correct, and how many are in the correct')
print('place in the code. The hint is printed as a', num, '-character string, where')
print(' * means correct color in correct place')
print(' o means correct color in incorrect place')
print(' - fills out remaining places to make', num)
print()
print('The player is allowed to make', maxGuesses, 'guesses. If the player guesses the colors')
print('in the correct order before all', maxGuesses, 'guesses are used, the player wins.')

gameOver = False
guesses = 0

code = genCode(colors, num)

while not gameOver:
guess = getGuess(colors, num)
guesses = guesses + 1
  
if matched(code, guess):
print('You win!')
gameOver = True
continue
  
hint = genHint(code, guess, colors, num)
print(hint)

if guesses == maxGuesses:
print('You took to many guesses. The code was', code)
gameOver = True

In: Computer Science

From the window of a building, a ball is tossed from a height y0 above the...

From the window of a building, a ball is tossed from a height y0 above the ground with an initial velocity of 8.40 m/s and angle of 25.0° below the horizontal. It strikes the ground 6.00 s later.

(a) If the base of the building is taken to be the origin of the coordinates, with upward the positive y-direction, what are the initial coordinates of the ball? (Use the following as necessary: y0. Assume SI units. Do not substitute numerical values; use variables only.) xi = Correct: Your answer is correct. yi = Correct: Your answer is correct.

(b) With the positive x-direction chosen to be out the window, find the x- and y-components of the initial velocity. vi, x = 7.61 Correct: Your answer is correct. m/s vi, y = -3.55 Correct: Your answer is correct. m/s

(c) Find the equations for the x- and y-components of the position as functions of time. (Use the following as necessary: y0 and t. Assume SI units.) x = Correct: Your answer is correct. m y = Correct: Your answer is correct. m

(d) How far horizontally from the base of the building does the ball strike the ground? 45.68 Correct: Your answer is correct. m

(e) Find the height from which the ball was thrown. 197.88 Correct: Your answer is correct. m

(f) How long does it take the ball to reach a point 10.0 m below the level of launching? 1.4 Incorrect: Your answer is incorrect.

Can you help me with (f)?

In: Physics

A vertical scale on a spring balance reads from 0 to 235 N . The scale...

A vertical scale on a spring balance reads from 0 to 235 N . The scale has a length of 10.5 cm from the 0 to 235 N reading. A fish hanging from the bottom of the spring oscillates vertically at a frequency of 2.65 Hz .

Ignoring the mass of the spring, what is the mass m of the fish?

Express your answer in kilograms.

In: Physics

A gas chromatogram of the organic components of a sample of beer using a column that...

A gas chromatogram of the organic components of a sample of beer using a column that separates compounds on the basis of their relative boiling points provides a GC trace with several peaks. Two of the smaller peaks, with retention times of 9.56 and 16.23 minutes, are believed to be ethyl acetate and ethyl butyrate, respectively.

a. From the above information, which component of the sample, ethyl acetate or ethyl butyrate, elutes faster? What are the reported boiling points of these two substances?

b. What GC experiment(s) could you perform to confirm the identity of the peaks at 9.56 and 16.23 minutes?

c. Suggest two ways in which you could adjust the conditions of the experiment so as to reduce the retention time for all components in the sample.

In: Chemistry

How much heat energy is required to convert 55.4 g of solid iron at 21 °C...

How much heat energy is required to convert 55.4 g of solid iron at 21 °C to liquid iron at 1538 °C? The molar heat of fusion of iron is 13.8 kJ/mol. Iron has a normal melting point of 1538 °C. The specific heat capacity of solid iron is 0.449 J/g·°C.

In: Chemistry

Q1. a. Given a schema R (A, B, C, D, E, F) and a set F...

Q1.
a. Given a schema R (A, B, C, D, E, F) and a set F of functional
dependencies {A → B, A → D, CD → E, CD → F, C → F, C → E, BD → E}, find the closure of the set of functional dependencies ?+

b. Given a schema R = CSJDPQV and a set FDs of functional dependencies FDs = {C → CSJDPQV, SD → P, JP → C, J → S}
1. Find the Canonical (Minimal) Cover set ? ?
2. Check whether the decomposition obtained by computing ? in step 1
in 3NF or not. Justify your answer.

c. Given R = (A, B, C, D) and F = {AB→C, AB→D, C→A, D→B} 1. Is R in 3NF, why? If it is not, decompose it into 3NF
2. Is R in BCNF, why? If it is not, decompose it into BCNF

In: Computer Science

Genetics: 1) Gametogenesis in Neuropsora is different from gametogenesis in humans and fruit flies in that...

Genetics:

1) Gametogenesis in Neuropsora is different from gametogenesis in humans and fruit flies in that it includes:

a) Only Meiosis II (i.e., Meiosis I does not occur)

b) Mitosis

c) Unordered gametes

d) Only Meiosis I (i.e., Meiosis II does not occur)

2) Assume that a true-breeding female with the dominant phenotype is crossed to a true-breeding male with the recessive phenotype (Generation 0). Female offspring are then backcrossed to males with the recessive phenotype (Generation 1). This process is then repeated, with each new generation created by crossing the female offspring from the previous backcross generation to males with the recessive phenotype. If this trait is controlled by a maternal effect gene, in which backcross generation will some of the females used for the backcross have the recessive phenotype?

a) 4

b) None. The recessive phenotype will never reappear with this crossing scheme.

c) 1

d) 3

e) 2

3) Consider the following parental cross, involving genes A and B that are located 10 cM apart on the same chromosome:

AB/AB x ab/ab

If the F1 individuals are backcrossed to the ab/ab parent, what percentage of the offspring are expected to have the genotype ab/ab?

Express your answer as an integer between 0 and 100.

4) Consider a dihybrid cross in which one allele at each of the two genes contributes a value of 2 to a trait whereas the other allele contributes 0.

What proportion of offspring are expected to have a phenotype of 4?

Enter your answer as a decimal with two places (e.g., 0.10 or 0.01).

In: Biology

Using the six stages of the moral development theory, explain why not steal a drug

Using the six stages of the moral development theory, explain why not steal a drug

In: Psychology

Refer to the table below. Given that 2 of the 127 subjects are randomly​ selected, complete...

Refer to the table below. Given that 2 of the 127 subjects are randomly​ selected, complete parts​ (a) and​ (b).

    Rh +   Rh -
O   43   12
A   31   10
B   11   4
AB   13   3

a. Assume that the selections are made with replacement. What is the probability that the 2 selected subjects are both group AB and type Rh +?

b. Assume the selections are made without replacement. What is the probability that the 2 selected subjects are both group AB and type Rh+?

In: Math

On a hot day with a temp of 35 celsius, you blow across the open end...

On a hot day with a temp of 35 celsius, you blow across the open end of an empty test tube and produce the fundamental standing wave for the air column inside the test tube. The test tube acts like a 22 cm pipe open at one end and closed at the other.

What is the fundamental frequency?

What is the frequency of the next possible Harmonic?

A person standing nearby records a sound level of 50 dB. What is the sound intensity measured by that person?

In: Physics

Q1. Discuss in your words the purpose of a bank reconciliation. (1 point) Q2. Prepare general...

Q1. Discuss in your words the purpose of a bank reconciliation. (1 point)

Q2. Prepare general journal entries for the following transactions of this company for the current year: (2 points).

Apr. 25

Sold SAR 4,500 of merchandise to CBC Corp., receiving a 10%, 60-day, SAR 4,500 note receivable.

June 24

The note of CBC Corp., received on April 25 was dishonored.

Q3. A company purchased mining property containing 7,350,000 tons of ore for SAR 1,837,500. In 2009 it mined and sold 857,000 tons of ore and in 2010 it mined and sold 943,000 tons of ore. (2 points).

a. Calculate the depletion expense for 2009 and 2010.

b. What was the book value of the property at the end of 2010?

Q4. Define liabilities and explain in your words the differences between current and long-term liabilities. (2 points).

In: Accounting

Choose the alternative the best answers the question. 6. Consider the following two Treasury securities: Bond...

Choose the alternative the best answers the question.


6. Consider the following two Treasury securities:

Bond Price Modified duration (years) A $100 6 B $ 80 7 Which bond will have the greater dollar price volatility for a 25-basis-point change in interest rates? a. Bond A b. Bond B

7. The breaking down of a system to gain insight into its compositional sub-systems is known as: a. Top down approach b. Bottom-up approach c. Quantitative approach

8. Being a senior secured debt holder in an investment grade corporation assures the investor that she will incur no loss on a credit default. a. True b. False


Calculate the requested measures in questions 10 through 12 for bonds A and B (assume that each bond pays interest semiannually):

   Bond A Bond B Coupon   8% 9% Yield to maturity 8% 8% Maturity (years)     2      5 Par   $100.00 $100.00 Price   $100.00 $104.055

9. What is the price value of a basis point for bond B only? a. 0.0181 b. 0.0416 c. 0.0597 d. 0.0746

10. Compute the approximate duration for bond A only using the shortcut formula by changing yields by 20 basis points a. 1.814948 b. 2.465732 c. 4.277338 d. 8.344402
11. Compute the approximate duration for bond B only using the shortcut formula by changing yields by 20 basis points a. 1.814948 b. 2.465732 c. 4.277338 d. 3.994507

12. Compute the approximate convexity measure for bond A only using the shortcut formula by changing yields by 20 basis points a. 1.814948 b. 2.465732 c. 4.277348 d. 3.994507

13. Compute the approximate convexity measure for bond B only using the shortcut formula by changing yields by 20 basis points a. 1.814948 b. 19.763824 c. 4.277348 d. 3.994507

14. Which U.S. Treasury securities do not make a coupon payment? a. Treasury Bonds b. Treasury Notes c. Treasury Bills d. All of the above

15. The most recently auctioned issue of treasury securities is called: a. On-the-run issue b. Off-the-run issue c. STRIPS issue d. Spot issue

16. Treasury securities are priced based on: a. The yield curve b. The theoretical spot rates c. The par coupon curve

17. Investment grade bond issues that were later downgraded to non-investment grade (junk) bonds are commonly known as: a. Dark angels b. Fallen angels c. Junk hybrids d. Bankruptcy candidates

18. Deferred coupon bonds that give the issuer the option to make a coupon payment with cash or with a similar bond is known as: a. Step-up bonds b. Deferred-interest bonds c. Payment-in-kind bonds

19. Which statement below is NOT correct? a. Eurobonds can be issued in various currencies b. Eurobonds are typically less liquid than Yankee bonds c. Eurobonds pay semi-annual coupons d. Eurobonds typically have weaker covenants than U.S. domestic bonds

20. Which bond warrant entitles the warrant owner to buy additional bonds from the issuer at the same price and yield? a. Equity warrant b. Debt warrant c. Currency warrant

21. A bond that is issued simultaneously in several bond markets throughout the world and can be issued in any currency is: a. Global bond b. Euro medium-term note c. Convertible bond d. Yankee bond

In: Finance

Discover why the conventional routing in wired networks is not suitable for wireless networks? Substantiate your...

Discover why the conventional routing in wired networks is not suitable for wireless networks? Substantiate your answer with suitable examples.

(20marks)
Learning Outcome
Demonstrate the architecture and principle of computer networks with wired and wireless communication.

In: Computer Science

C++ When an object is falling because of gravity, the following formula can be used to...

C++ When an object is falling because of gravity, the following formula can be used to determine the distance that object falls in a specific time period: d = 1/2 g t*t The variables in the formula are as follows: d is the distance in meters g is 9.8 t is the amount of time, in seconds that the object has been falling. Design a function called fallingDistance() that accepts an object's falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Design a program that calls the function in a loop that passes the values 1 through 10 as arguments and displays the return value. 5 Falling Distance (5 points) Seconds Meters 1.0 4.9 2.0 19.6 3.0 44.1 4.0 78.4 5.0 122.5 6.0 176.4 7.0 240.10000000000002 8.0 313.6 9.0 396.90000000000003 10.0 490.0

In: Computer Science

Can anyone explain all the answer? 1. Horizontal force needed to keep a sled moving along...

Can anyone explain all the answer?

1. Horizontal force needed to keep a sled moving along dry (it means not wet) horizontal surface is 10 N. You increase this force up to 20 N. Neglect air resistance.  What can you say about character of motion of a sled now?

a. Sled will continue to move with the same speed.

b. Sled will accelerate for a while up to higher speed and then move with constant, higher speed.

c. Sled will accelerate indefinitely.

d. Sled will move with constant speed two times greater than initial.

2. You try to move a refrigerator of weight 2000 N applying force of 500 N. Refrigerator does not move. The force of friction acting of refrigerator is:

a. 2000 N

b. More than 500 N but less than 2000 N

c. Slightly less than 500 N

d. 500 N

e. Zero.

3. A person rides an elevator standing of a bathroom scale (people are doing strange things). Elevator moves up with constant velocity. What will be the reading of a bathroom scale?

a. more than mg

b. mg

c. less than mg

d. zero

4. Some force acts on an object sitting on the horizontal surface and it accelerates. We increase force twice and perform experiment again. If surface is frictionless, the acceleration of an object will increase:

a. Less than two times

b. Exactly twice

c. More than twice

d. Stays the same.

5. An object is sitting at rest on a horizontal table. Which one of Newton’s laws predicts that normal force acting on this object is equal in magnitude and opposite in direction to the force of gravity (weight) acting on this object?

a. First

b. Second

c. Third

d. Law of gravitation.

In: Physics