answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ipatiy [6.2K]
1 year ago
7

Modify the guessing-game program so that the user thinks of a number that the computer must guess.

Computers and Technology
1 answer:
Triss [41]1 year ago
7 0

Answer:

import random

import math

smaller = int(input("Enter the smaller number: "))

larger = int(input("Enter the larger number: "))

count = 0

print()

while True:

   count += 1

   myNumber = (smaller + larger) // 2

   print('%d %d' % (smaller, larger))

   print('Your number is %d' % myNumber)

   choice = input('Enter =, <, or >: ')

   if choice == '=':

       print("Hooray, I've got it in %d tries" % count)

       break

   elif smaller == larger:

       print("I'm out of guesses, and you cheated")

       break

   elif choice == '<':

       larger = myNumber - 1

   else:

       smaller = myNumber + 1

Explanation:

The code to be Modified is as indicated below:

# Modify the code below:

import random

smaller = int(input("Enter the smaller number: "))

larger = int(input("Enter the larger number: "))

myNumber = random.randint(smaller, larger)

count = 0

while True:

   count += 1

   userNumber = int(input("Enter your guess: "))

   if userNumber < myNumber:

       print("Too small")

   elif userNumber > myNumber:

       print("Too large")

   else:

       print("You've got it in", count, "tries!")

       break

Detailed Explanation:

Line 3 and 4 of the codes prompts the user to enter a smaller and larger number. Line 5 we initiate the formula for minimum number of guesses. Line 14 and 17 prints out the output  I'm out of guesses, and you cheated and Hooray, I've got it in X after validating the conditions.

You might be interested in
When a file is transferred between two computers, two acknowledgment strategies are possible. in the first one, the file is chop
ra1l [238]
The TCP/IP stack is responsible for the "chopping up" into packets of the data for transmission and for their acknowledgment. Depending on the transport protocol that is used (TCP or UDP) each packet will be <span>acknowledged or not, respectively.
</span><span>the strategy when the file is chopped up into packets, which are individually acknowledged by the receiver, but the file transfer as a whole is not acknowledged is OK in situations (Applications) that do not need the whole file to be sent, Web site for example: different parts of the web site can arrive in different times.

The other strategy, in which </span><span>the packets are not acknowledged individually, but the entire file is acknowledged when it arrives is suitable for FTP (mail transfer), we need whole mail, not parts of it. </span>
5 0
2 years ago
The vast amount of data collected from Internet searches, social media posts, customer transactions, military
Brums [2.3K]

Answer:

A. Big Data

Explanation:

It is big data. The internet searches, customer transactions, social media posts, medical tests, weather sensors, military surveillance, and all the data source you are seeing around yourself forms together with the big data. And a big social media company gathers around so many petabytes of data each day. And there are so many such companies, plus all sorts like eLearning sites, etc. And all these together form the big data.

3 0
2 years ago
Describe the ways in which a computer-aided design (CAD) drawing makes the details of an image easier to understand.
cupoosta [38]

Answer: CAD is mainly used for detailed engineering of 3D models or 2D drawings of physical components, but it is also used throughout the engineering process from conceptual design and layout of products, through strength and dynamic analysis of assemblies to definition of manufacturing methods of components.

Explanation:

3 0
2 years ago
Read 2 more answers
Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable val_of_m
geniusboy [140]

Answer:

Here is the Python program:

d = {5:3, 4:1, 12:2}

val_of_max = d[max(d.keys())]

print(val_of_max)

Explanation:

The program works as follows:

So we have a dictionary named d which is not empty and has the following key-value pairs:

5:3

4:1

12:2

where 5 , 4 and 12 are the keys and 3, 1 and 2 are the values

As we can see that the largest key is 12. So in order to find the largest key we use max() method which returns the largest key in the dictionary and we also use keys() which returns a view object i.e. the key of dictionary. So

max(d.keys()) as a whole gives 12

Next d[max(d.keys())]  returns the corresponding value of this largest key. The corresponding value is 2 so this entire statement gives 2.

val_of_max = d[max(d.keys())] Thus this complete statement gives 2 and assigns to the val_of_max variable.

Next print(val_of_max) displays 2 on the output screen.

The screenshot of program along with its output is attached.

4 0
2 years ago
Iris called the company’s security hotline. The hotline is an anonymous way to report suspi- cious activity or abuse of company
marishachu [46]

Answer 1 :

if Iris had approached Henry, it might had become a personal matter rather than professional. Following the proper protocol is the best way to report in any organization.

Answer 2 :

Yes, Gladys should call the legal authorities. Federal Trade Commission (FTC) is the best agency to file a complaint prevention of corruption within a company.

Answer 3 :

Yes, she should have followed her chain of command because that is one of the many questions that an investigator will ask is if she reported it to her supervisor and human resources. Somehow in companies they use that term when it is somewhat of a legal issue. Internally if she knew the IT director and the security office she could have gone to them along with human resources. Outside I would say start with her local police department and they may have directed her to the proper channel.

Answer 4 :

What Henry did was not ethical even in the slightest. He used the flash drive without permission from the company, he knew he shouldn’t have, but he did it anyway. It is acted in a complete ethical way. If Iris had left this in a coffee station and forgot about it, then it would have been unethical behavior because she knew about it but didn’t whistle blow. There are security laws that get violated in this issue which is why it is unethical and troublesome.

5 0
2 years ago
Other questions:
  • When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being
    11·2 answers
  • Write the prototype for a function named showValues. It should accept an array of integers and an integer for the array size as
    14·3 answers
  • The process of converting information, such as text, numbers, photos, or music, into digital data that can be manipulated by ele
    7·1 answer
  • Constantine forms the following hypothesis. Let n be any non-negative number that meets the following condition: when n is divid
    10·1 answer
  • Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi
    8·1 answer
  • As part of the duties of a digital forensics examiner, creating an investigation plan is a standard practice. Write a 3 to 4 (no
    9·1 answer
  • Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
    10·1 answer
  • Server farms such as Google and Yahoo! provide enough compute capacity for the highest request rate of the day. Imagine that mos
    12·1 answer
  • Krista needs to configure the default paste options in PowerPoint 2016. Which area of the Options dialog box will she need to us
    14·1 answer
  • Which of the following is true of how computers represent numbers?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!