Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python 3 question the question marks need filled information i have been stuck on all day - Picode complete T wilig cue as instructed. 15

python 3 question the question marks need filled information i have been stuck on all day
image text in transcribed
image text in transcribed
- Picode complete T wilig cue as instructed. 15 points # Please try to understand above code. # Based on your understanding of the above code, you will be doing a fun exercise In this exercise you are supposed to make a simple game Following are the rules: You will run a while loop utill the game is finished You will create one random target number between 1 to 100 inclusively, # Ask user to guess the number # If the guess is high, the program says high, if it is low, it says low If match the game is finished # You will count how many steps a user will require to finish Note : You will see a try-except block for Exception handling. # Research about this to learn more. T # Now complete the code import random random.seed() attempts - 2 Winitialize the counter here goal_number - 20 #should be between 1 to 100 inclusiveley, don't print this, it is cheating while(True): We don't wan't to abort our program flow . So we want to catch sone errors if happened and handle try: guess_nun - int (input('Please Guess The Number : )) We want to confirm user gave us number between 1 to 100 assert guess_num in range(1,100) except: print('this is the correct assumption') # Print Appropriate message here # Here remember if high, say high, if low, say low and increment the counter # Remember you are supposed to use the continue statement whenever necessary # Google the use of continue statement and use it properly Note you may have multiple lines of code inside each block if necessary If : elif : else: print('Wow you did it in break attempts) attempts') File " ", line 22 if guess num=20 Type here to search Question no. 12: Study about for loop from documentation. And try to solve following question as instructed. [10 points) [# Let us see one example called prime-finder # A prime number is a number that is divisible by itself or 1 only x = int(input('Enter a number to check for prime :)) . Following is an algorithm to find if a number is prime Algorithm 1. Begin 2. Assign input to x 3. For 1-2...sart(x) Inclusively check if x is divisible by i, if divisble 'break! loop and say no prime 4. In 3 if loop never breaks x is a prime number, it, if i sort(x) it is a prime number, Print x as prime number . We will code above using for loop but code is incomplete code Complete the code, you can use math.sqrt() to calculate square nypber . Note that range won't take floating value you have to convert it to int, and remember inclusiveness import math isprime = True for i in range(?,?): 14 7: 12

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions