1answer.
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
faltersainse [42]
3 years ago
11

**GIVING ALL POINTS** 4.02 Coding With Loops

Computers and Technology
1 answer:
Anestetic [448]3 years ago
3 0

Answer:

import random

from time import sleep as sleep

 

def main():

   # Initialize random seed

   random.seed()

 

   # How many guesses the user has currently used

   guesses = 0

   

   # Declare minimum value to generate

   minNumber = 1

 

   # Declare maximum value to generate

   maxNumber = 20

 

   # Declare wait time variable

   EventWaitTime = 10 # (Seconds)

 

   # Incorrect config check

   if (minNumber > maxNumber or maxNumber < minNumber):

       print("Incorrect config values! minNumber is greater than maxNumber or maxNumber is smaller than minNumber!\nDEBUG INFO:\nminNumber = " + str(minNumber) + "\nmaxNumber = " + str(maxNumber) + "\nExiting in " + str(EventWaitTime) + " seconds...")

       sleep(EventWaitTime)

       exit(0)

 

   # Generate Random Number

   secretNumber = random.randint(minNumber, maxNumber)

 

   # Declare user guess variable

   userGuess = None

 

   # Ask for name and get input

   name = str(input("Hello! What is your name?\n"))

 

   # Run this repeatedly until we want to stop (break)

   while (True):

 

       # Prompt user for input then ensure they put in an integer or something that can be interpreted as an integer

       try:

           userGuess = int(input("Guess a number between " + str(minNumber) + " and " + str(maxNumber) + ": "))

       except ValueError:

           print("ERROR: You didn't input a number! Please input a number!")

           continue

 

       # Increment guesses by 1

       guesses += 1

 

       # Check if number is lower, equal too, or higher

       if (userGuess < secretNumber):

           print("You guessed: " + str(userGuess) + ". Too low.\n")

           continue

       elif (userGuess == secretNumber):

           break

       elif (userGuess > secretNumber):

           print("You guessed: " + str(userGuess) + ". Too high.\n")

           continue

   

   # This only runs when we use the 'break' statement to get out of the infinite true loop. So, print congrats, wait 5 seconds, exit.

   print("Congratulations, " + name + "! You beat the game!\nThe number was: " + str(secretNumber) + ".\nYou beat the game in " + str(guesses) + " guesses!\n\nThink you can do better? Re-open the program!\n(Auto-exiting in 5 seconds)")

   sleep(EventWaitTime)

   exit(0)

 

if __name__ == '__main__':

   main()

Explanation:

You might be interested in
The use of encryption and authentication protocols is the standard method of countering attempts to alter or insert transmission
enyata [817]

Answer:

a) true.

Explanation:

Encryption is a form of cryptography and typically involves the process of converting or encoding informations in plaintext into a code, known as a ciphertext. Once, an information or data has been encrypted it can only be accessed and deciphered by an authorized user.

Some examples of encryption algorithms are 3DES, AES, RC4, RC5, and RSA.

On the other hand, authentication can be defined as the process of verifying the identity of an individual or electronic device. Authentication work based on the principle of matching an incoming request from a user or electronic device to a set of uniquely defined credentials.

Basically, authentication ensures a user is truly who he or she claims to be, as well as confirm that an electronic device is valid through the process of verification.

Digital certificates, smart cards, picture passwords, and biometrics are used to perform an authentication.

<em>Hence, in cybersecurity the use of encryption and authentication protocols is the standard method of countering attempts to alter or insert transmissions. </em>

5 0
3 years ago
Use the following data definitions data myBytes BYTE 10h,20h,30h,40h myWords WORD 3 DUP(?),2000h myString BYTE "ABCDE" What will
Elena-2011 [213]

Answer:

<em>Given Data:</em>

<em>myBytes BYTE 10h, 20h, 30h, 40h </em>

<em>myWords WORD 3 DUP(?), 2000h </em>

<em>myString BYTE "ABCDE"</em>

<em />

Based on the data that we are given we can conclude that:

(a).     a. EAX = 1

         b. EAX = 4

         c. EAX = 4

         d. EAX = 2

         e. EAX = 4

         f. EAX = 8

         g. EAX = 5

8 0
3 years ago
This program is to compute and write to a file the GPA for student scores read from an input file. The point values of the grade
VARVARA [1.3K]

Answer:

#Take input from the user

filename=input('Enter name of input file: ')

total_units=0#Total number of units for a student

total_score=0#Total score of a student

#Assign a score to each grade. I have reduced 0.33 for each grade. Change here if you need to

grade={'A':4.0,'A-':3.67,'B+':3.34,'B':3.01,'B-':2.68,'C+':2.35,'C':2.02,'C-':1.69,'D+':1.36,'D':1.03}

try:

with open(filename,"r") as input_file:#Open the file for input(reading)

output_file=open("GPA_output.txt","w") #Create and open GPA_output.txt if it doesn't exist for writing

for student_record in input_file:#read from input file

if("," in student_record):#if there is a , that means this is the student name

student_name=student_record.strip('\n')#Remove \n from student name

continue

else:

if(" " in student_record):#If a line contains spaces then its the student's grades for a course

student=student_record.split(" ")#Split to find the coursename, units and grade

#student[0]=coursename student[1]=units student[2]=grade

total_units+=int(student[1])#Calculate total units for 1 student

total_score+=int(student[1])*grade[student[2].strip('\n')]#Find the total score of a student

#grade[student[2]] will lookup for the score that we initialized earlier

#if student has a grade as A then this will look up as grade['A'] which will return 4

#Find the total score as product of this grade and units for this course

continue

else:

if(total_units>0):#Check if score has been calculated for a student earlier

print("in")

GPA=total_score/total_units#Calculate the GPA

output_file.write("%-26s%.2f\n" % (student_name, GPA))#Write the GPA and Student Name in the required format

total_units=0#reset the units

total_score=0#reset the score

if(total_units>0):#Essential for the case when the file doesn't end with a new line(Check if total_units is not 0) which means a record is pending

#to be written to the file

GPA=total_score/total_units#Calculate the GPA

output_file.write("%-26s%.2f\n" % (student_name, GPA))#Write the GPA and Student Name in the required format

total_units=0#reset the units

total_score=0#reset the score

input_file.close()#Close the input file

output_file.close()#Close the output file

except IOError as e:

print("Problem in Opening the required file")#Print a message if file cannot be opened

Explanation:

The program has been tested for all 3 scenarios mentioned i.e.

a. If the file ends without \n

b. If the file ends with 2 \n

c. If the file ends with 1 \n

PS: The Program will run irrespective of how it ends. Even if there are many \n at the end of file, the program will be fine.

3 0
3 years ago
There is a huge demand for cyber security professionals. True or false
STatiana [176]
True.
Thank You!
Please mark Brainliest
5 0
4 years ago
Read 2 more answers
Which of the following statements are true regarding technology and learning? Select 3 options.
bekas [8.4K]

Answer:

<h2>Knowledge can be acquired throughout your life, through both formal and informal methods.</h2>

As long as a person is alive, they can keep learning. With the amount of knowledge available in the world, it is improbable that a person can acquire all of it before they pass on. It is therefore possible to acquire information until the day a person dies.

<h2>Changes in technology both enable and require lifelong learning.</h2>

Technology keeps changing and developing in order to make things better and more efficient. As such, humans need to keep learning for their entire lives or else they will be left behind as newer technology comes out. Take smartphones for instance, a lot of older grandparents have had to learn how to use them to keep in contact with with their families.

<h2>Virtual reality simulations are being used for training in industries like healthcare and the armed forces.</h2>

Virtual reality has improved the effectiveness of training in both the medical and armed forces industry because with training capable of being done in a virtual world, it can be more in-depth. For instance, medical students can use more realistic subjects to learn the intricacies of the human body and soldiers can embark on dangerous training missions without actually risking their lives.

5 0
3 years ago
Other questions:
  • The eastern front was longer than other fronts of the war true or false
    7·2 answers
  • The physical address assigned each network adapter is called its ________.
    6·1 answer
  • Given the following code segment, what is output after "result = "? int x = 1, y = 1, z = 1; y = y + z; x = x + y; cout &lt;&lt;
    7·1 answer
  • Try writing pseudo code that describes how your device uses input data to perform the action that you want.
    9·1 answer
  • Asian-American men are often represented in the media as _____.
    8·2 answers
  • A bank uses a computer program during the night to tell if the alarm should ring. Sensors in the bank set the following Boolean
    5·1 answer
  • Match each sentence to the type of imperialism it describes.
    11·1 answer
  • Why would it be unusual to find a fossil of an organism’s eye?
    11·1 answer
  • Write a program that prompts the user to enter a number then counts the number of odd numbers and even numbers the user enter. T
    15·1 answer
  • Es la actividad que posibilita comunicar gráficamente ideas, hechos y valores procesados y sintetizados en términos de forma y c
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!