Question


1.Comparing Python and Java Discussion Forum 14 days ago Use the Python IDLE editor to create the source code for the numbergu
program to use with number 1.
numberguess.py Program The mumberguess py program in the Python IDLE editor t numberqueoy CFtes GhMOGMC CI21amplesumbergues


2.
Data Structures Primary Be- haviors Discussion Forum 15 days ago As defined in the textbook slides: A data structure is a se


ww Author: Ken Lambert Plays a game of guess the number with the user. import random def main (): wwInputs the bounds of the
RE >>> >>> Enter the smaller number: 1 Enter the larger number: 100 Enter your guess: 50 Too small Enter your guess: 75 Too l
Comparing Python and Java Discussion Forum 14 days ago Use the Python IDLE editor to create the source code for the "numberguess.py" pro- gram. This program is in the "Basic Python Pro- gramming" chapter in its "An Example Python Program: Guessing a Number" section. If you mistakenly create syntax errors, find and fix them. Run the program and test it with various values. Refer to the "numberguess.py Program document to see example output. Describe the number guessing strategy you used to guess the program's secret number in as few guesses as possi- ble. Research the "binary search algorithm" and compare it to your guessing strategy. Look over the program to find differences between Python and Java. Describe some of the differences you find. Are they major or minor differences? Evaluate some of the differences you find. Which do you prefer and why?
numberguess.py Program The "mumberguess py' program in the Python IDLE editor t numberqueoy CFtes GhMOGMC CI21amplesumberguesspy .4.33 F t Fome u Wn H ushe P e he er wish he e t npes eand et sass e d et the sg ot rs ae s ge te er a put er e e ay n c taller, age cout a qu your gue st ueuge a pes o got it i, count,e The next page shows example output Eample outout Python 3.43 Shell Tre "oregh eredst er "im for more anformenson ESTART ter the aier rs Esser your que Tee arge ma tsse you quea a
Data Structures Primary Be- haviors Discussion Forum 15 days ago As defined in the textbook slides: "A data structure is a set of data objects that are organized in some way. "A collection is a container for zero or more data objects. "An abstract data type (ADT) separates the user or client of a data structure from the implementer or server "An ADT provides an interface or public set of abstract operations for accessing the ob- jects in the data structure. We see that data structures, collections, and abstract data types are closely related concepts. Objects that are contained within these en- tities are typically called items or elements. From the object-oriented perspective, data structures have both private data and public behaviors. The behaviors define data structures in an abstract, implementation independent man- ner Other equivalent terms used for behaviors are operations, methods, public interface, and usage interface. In this discussion, we explore the primary behaviors needed to use data structures Some of these behaviors include: Determine its size (number of items) Test for item membership (presence or absence of an item) -Traverse through all its items -Get an item -Insert an item -Remove an item Replace an item Discuss these behaviors You don't have to address them all Select one or more that interest you What do they do? Are they needed or simply convenient? How are they the same across different types of data structures? How do they vary across different types of data structures? Do they have any efficiency issues? You could give a real-world example for one of the behaviors You could give a visual depiction of one of the behaviors. You could discuss other primary behaviors not listed here.
ww Author: Ken Lambert Plays a game of guess the number with the user. import random def main (): "wwInputs the bounds of the range of numbers, and lets the user guess the computer's number until the guess is correct."" 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 if userNumber myNumber: print ("Too large ") ")) your guess: else: print ("You've got it in", count, "tries! ") break if main ( name main he next page shows example output
RE >>> >>> Enter the smaller number: 1 Enter the larger number: 100 Enter your guess: 50 Too small Enter your guess: 75 Too large Enter your gue ss: 60 Too small Enter your guess: 65 Too small Enter your guess: 70 Too large Enter your guess: 67 Too small Enter your quess: 68 You've got it in 7 tries!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a.py C/Users/delll/a.py (3.6.2) File Edit Format Run Options Window Help import random def main ( smaller-int (input (EnterPython 3.6.2 Shell File Edit Shell Debug Options Window Help Python 3.6.2 (v3.6.2:5 fd3 3b5, Jul Type copyright, credits

source code given in  numberguess.py uses a logic that is completely based on random numbers.

it is not possible to describe the strategy of source code of numberguess.py.

code given below is based on the following strategy

1)it is based on binary search

2)It has a list of integers in ascending order

3)minimun value is 4 and maximum value is 18

4.if user input is less than 6, number will be small.

5. if user input is greater than 10 number is Large

6. if user input is not present in the list of integers, then guess is too far away from the expectation.

b.py-C:/Users/delll/b.py (3.6.2) File Edit Format Run Options Window Help def bin_Search (list2, item) : first= 0 last len (lPython 3.6.2 Shell File Edit Shell Debug Options Window Help 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel) ]on win32 Python 3.code given below uses following strategy

1)It uses exception handling

2)user input less than 10 is small

3)user input greater than 10 is large

4 only user input 10 is correct

c.py-C:/Users/delll/c.py (3.6.2) File Edit Format Run Options Window Help class ValueToo Small (Exception) (self,arg) : def iPython 3.6.2 Shell File Edit Shell Debug Options Window Help 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel) ]on win32 Python 3.

Python vs java

1)python code is simple, java code is difficult

2)python code is small(compact), java code is large.

d.py -C:/Users/delll/d.py (3.6.2) File Edit Format Run Options Window Help listl-[1,3,6,2,7,5,8,9,3,5] #size print (Size ofPython 3.6.2 Shell File Edit Shell Debug Options Window Help Close 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel) ]on win32 Pyt

simirarily
all the above behavior are required in all datastructures
because there is a need to search item/delete item/mofify item/traverse and so on.
these operations are required in every data structure

difference
there are two types of data structures
1)linear
2)non linear

there is more complexity to perform above operation in case of non linear data structure such as tree graph .


Add a comment
Know the answer?
Add Answer to:
1. program to use with number 1. 2. Comparing Python and Java Discussion Forum 14 days ago Use the Python...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please enter this python program code into an IPO Chart? import random def menu():...

    Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • python Exercise: ex9.py Write a program that plays a number and you guess the number. The...

    python Exercise: ex9.py Write a program that plays a number and you guess the number. The program helps you with a response 1t the number you guessed is higher or lower than the mystery number. To generate a random number, we need to import some routines. guessing game. It generates a random mystery import random mysteryNumber random.randint (1, 100) The random.randint (1, 100) creates a random integer between 1 and 100. Here is a sample output: Let's play the guessing...

  • Write a Java program that implements the number guessing game where the computer tries to guess...

    Write a Java program that implements the number guessing game where the computer tries to guess a number in your head. You pick a number between 0 and 100, and the computer generates a guess. You then type 1 if your number is larger than the computer’s guess, -1 if your number is smaller, and 0 if the number is correct. The computer should keep trying to guess the number by adjusting the guess based on your feedback (so if...

  • python code for guessing game users enter the number the computer will guess 8:38 PM 100...

    python code for guessing game users enter the number the computer will guess 8:38 PM 100 nstructure.com 1. Number guessing game : (5 points) 1) Requirements: Your program will ask the user to enter a number between 1 and 1000. Then it will try to guess the correct number with the guaranteed minimal average number of guesses. Which search algorithm should you use? 2) Expected Output: Enter a number between 1 and 1000? 784 Computer guesses: 500 Type 'l' if...

  • USE JAVA Problem 1: Guess a Number You are writing a program for a number guessing...

    USE JAVA Problem 1: Guess a Number You are writing a program for a number guessing game. For playing "Guess a Number", the program will generate a number for player to guess from within a range specified by the player. The program will take as input the lowest number in the range and the highest number in the range from the player, and then a series of guesses of the form: <n,>n, = n, where n is the number guessed....

  • Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number...

    Python Program Python: Number Guessing Game Write a Python function called "Guess.py" to create a number guessing game: 1. Function has one input for the number to Guess and one output of the number of attempts needed to guess the value (assume input number will always be between 1 and 1000). 2. If no number was given when the function was called, use random.randint(a,b) to generate a random number between a=1 and b=1000. You will also need to add an...

  • Hello! we are using Python to write this program. we are supposed to use loops in...

    Hello! we are using Python to write this program. we are supposed to use loops in this assignment. I would greatly appreciate the help! Thank you! Write a program that allows the user to play a guessing game. The game will choose a "secret number", a positive integer less than 10000. The user has 10 tries to guess the number. Requirements: we would have the program select a random number as the "secret number". However, for the purpose of testing...

  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • JAVA PROGRAM: Guessing Game Objective The student will write an individualized program that utilizes conditional flow...

    JAVA PROGRAM: Guessing Game Objective The student will write an individualized program that utilizes conditional flow of control structures in Java. Specifications For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT