PYTHON Exercise 5. Guess the number
1. Develop a “Guess the number” game. Write a program that comes up with a random number and the player has to guess it. The program output can be like this: I am thinking of a number between 1 and 20. Take a guess. 10 Your guess is too low. Take a guess. 15 Your guess is too low. Take a guess. 17 Your guess is too high. Take a guess. 16 Good job! You guessed my number in 4 guesses!
2. Complicate it by having random lower and upper bounds. Make sure your lower bound is not higher than you upper bound!
3. Now, instead of user input make the code guess it automatically. Make sure that for the automatic guesses you don’t use the number to guess.
In: Computer Science
Challenge: Number Stats 2
Description: Extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file.
Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information including the determination of median and mode. It also provides experience adding new functionality to an existing program.
Requirements:
Extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file.
You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following:
The output from the program is to display the information described above using the following strings preceding the values. There is to be a space between the colon and the value.
File name:
Sum:
Count:
Average:
Maximum:
Minimum:
Range:
Median:
Mode:
At the end of one attempt at reading, or a successful read, of a file the user it to be asked if they would like to evaluate another file of numbers. Use the prompt: Would you like to evaluate another file? (y/n) If the user answers y, then the program is to accept input for another file name. If the user answers with anything other than y, the program is to exit.
The program you write must be able to handle four different circumstances for the file that contains the number data:
EDIT:
file 1:
728
44
591
586
660
852
554
419
451
698
947
660
170
396
627
975
748
13
373
881
112
266
500
476
951
433
409
786
592
251
324
930
148
785
101
929
583
505
487
175
995
875
913
620
444
806
259
8
893
637
635
238
140
989
476
438
835
641
650
904
268
798
464
716
918
377
332
691
981
370
747
217
668
777
475
322
362
540
209
300
884
245
375
400
915
331
765
522
222
849
907
461
507
976
575
671
755
901
263
542
file 2:
728
44
591
586
660
852
554
419
451
698
947
660
170
396
627
975
748
13
373
881
112
266
500
476
951
433
409
786
592
251
324
930
148
785
101
929
583
505
487
175
995
875
913
620
444
806
259
8
893
637
635
238
140
989
476
438
835
641
650
904
268
798
464
716
918
377
332
691
981
370
747
217
668
777
475
322
362
540
209
300
884
245
375
400
915
331
765
522
222
849
907
461
507
976
575
671
755
901
263
file 3:
728
file 4 is completely blank.
For the provided numbers.txt file the following are the values your program should generate:
Sum: 56110
Count: 100
Average: 561.1
Maximum: 995
Minimum: 8
Range: 987
Median: 564.5
Mode: [660, 476]
For the provided numbers2.txt file the following are the values your program should generate:
Sum: 55568
Count: 99
Average: 561.2929292929293
Maximum: 995
Minimum: 8
Range: 987
Median: 575
Mode: [660, 476]
For the provided numbers3.txt file the following are the values your program should generate:
Sum: 728
Count: 1
Average: 728.0
Maximum: 728
Minimum: 728
Range: 0
Median: 728
Mode: [728]
For the provided numbers4.txt file the program should generate:
There are no numbers in numbers4.txt
THANK YOU!! (:
In: Computer Science
In: Computer Science
Using pseudocode design a number guessing game program. The program should generate a random number and then ask the user to guess the number. Each time the user enters his or her guess, the program should indicate it was too high or too low. The game is over when the user correctly guesses the number. When the game ends, the program should display the number of guesses that the user made.
In: Computer Science
Prompt user to enter an integer number from console. Use 2 methods to multiply this number by factor 7, display result. This is required to be done in MIPS Assembly Language.
In: Computer Science
Create your own function in C that accepts one input number and returns a double number. The themes for the functions should be one of the following: Calculates 3.14 times of the square of input number. For example, if 2 is input then 12.56 should be returned. (e.g. 3.14*2*2 = 12.56)
In: Computer Science
1. If you stored the following binary number (-0.000000100101) as a binary floating point number, what value would be STORED in the exponent section? Also convert A7.11 Hex value to floating point.
2. Number of bits saved using Huffman encoding. From the following characters used in a message with their associated frequency, use Huffman Coding as a compression technique. How many bits will be saved in the message? (Keep in mind that one character is one byte which consists of 8 bits). Draw the associated Huffman Tree to help calculate your answer. Show all your work. (15 points)
Character Frequency
|
A |
6 |
|
B |
11 |
|
C |
13 |
|
D |
14 |
|
E |
19 |
|
F |
47 |
In: Computer Science
Create your own function in C that accepts one input number and returns a double number. The themes for the functions should be one of the following:
Divides the number by 3 and returns the result. For example, if 6 was input then 2.0 should be returned.
provide both your C code and an example call to the C code function. Be sure to provide an overview of what your function is doing. Include header documentation in the code as well as internal code documentation.
In: Computer Science
Java Counter Program
I can't get my program to add the number of times a number was landed on for my if statements for No12 through No2.
My Code:
import java.util.Scanner;
import java.util.Random;
import java.lang.*;
public class Dice
{
public static void main(String[]
args)
{
Scanner in = new
Scanner(System.in);
int Continue =
1;
//randomnum =
new Random();
do
{
RollDice();
System.out.print("Would you like to go again? (Yes = 1, No
=2");
Continue =
in.nextInt();
}while(Continue
== 1);
}
public static void RollDice ()
{
Scanner in = new
Scanner(System.in);
//int die1;
//int die2;
int dieTotal;
int times;
int rollCount =1;
int i,temp=0;
int rollCounto = 1;
int
No12=0;
int
No11=0;
int
No10=0;
int No9=0;
int No8=0;
int No7=0;
int No6=0;
int No5=0;
int No4=0;
int No3=0;
int No2=0;
Random
diceRoller = new Random();
System.out.print("Enter amount of rolls
desired");
for(i=0; i<rollCounto;i++)
{
rollCounto =
in.nextInt();
rollCount =
rollCounto;
do
{
int die1 = diceRoller.nextInt(6) +1;
int die2 = diceRoller.nextInt(6) +1;
dieTotal = (die1 + die2);
if(dieTotal == 12)
{
No12=
No12++;
}
if(dieTotal == 11)
{
No11=
No11++;
}
if(dieTotal == 10)
{
No10=
No10++;
}
if(dieTotal == 9)
{
No9= No9++;
}
if(dieTotal == 8)
{
No8= No8++;
}
if(dieTotal == 7)
{
No7= No7++;
}
if(dieTotal == 6)
{
No6= No6++;
}
if(dieTotal == 5)
{
No5= No5++;
}
if(dieTotal == 4)
{
No4= No4++;
}
if(dieTotal == 3)
{
No3= No3++;
}
if(dieTotal == 2)
{
No2= No2++;
}
rollCount = (rollCount - 1);
}while(rollCount
>0);
System.out.println("\n2 | " + No2 + "/36" + "\n3 | " + No3 + "/36"
+ "\n4 | " + No4 + "/36" + "\n5 | " + No5 + "/36" + "\n6 | " + No6
+ "/36" +
"\n7 | " + No7 +
"/36" + "\n8 | " + No8 + "/36" + "\n9 | " + No9 + "/36" + "\n10 | "
+ No10 + "/36" + "\n11 | " + No11 + "/36" + "\n12 | " + No12 +
"/36");
break;
}
}
}
In: Computer Science
Number conversion between hexadecimal and binary. Show the working steps. a) Convert the hexadecimal number E4D2 into binary. b) Convert the binary number 1100010111110011 into hexadecimal
In: Computer Science