Write a program in Python to determine how many months it will take to pay off a $10,000 car loan with 4% interest. Choose your own monthly payment.
In: Computer Science
PYTHON
The game of Morra is a hand game that dates back to ancient Greece and Rome. In the real game, any number of players can play, but for this question we will assume two players only. The game is played in rounds. Each round, both players throw out one hand showing between 0 and 5 fingers and simultaneously call out what they think the sum of the fingers on the hands of all players will be. Any player who guesses correctly gets a point. The first player to 3 points wins. You will write a program that simulates a two-player game of Morra. Your program must do the following for each round of play until the game is over: • At the beginning of each round, print out the round number. The first round is round 1. • Read from the console the number of fingers shown by player 1, the number of fingers shown by player 2, player 1’s guess at the sum, and player 2’s guess at the sum. • Print to the console whether any players made a correct guess, and if so, that player’s new point total. If neither player guessed correctly, print a message indicating this. Note that BOTH players might guess correctly, in which case they both earn a point! Once the game is over, print the final outcome of the game. There are a few possibilities: • Print Player X wins! where X is either 1 or 2 depending on which player won. • If, however, the winning player won by a score of 3 to 0, instead print Player X wins a glorious victory!, again where X is either 1 or 2 as appropriate. • It is possible that the game is a tie. For example, if the score is 2 to 2, and both players guess correctly in the next round, both players will have three points when the game ends. In such a case, instead of printing either of the above messages, print It’s a tie!.
(a) Remember: you don’t have to generate player moves randomly. You are reading them from the console each round. Think of your program as the referee — it asks for the players moves each round using console input, then reports on the outcome of each round using console output, and finally prints the outcome of the game. (b) Your program only has to play one full game. To referee another game, run the program again! (c) You may assume that the user enters only valid data. That is, you do not have to actually check whether player moves are between 0 and 5 and that their guesses are between 0 and 10. Just assume that valid values are always entered.
In: Computer Science
Minicomputers were developed to take advantage of the use of transistors.
True
False
This technique breaks up a message into smaller pieces for transmission over a network.
|
Slicing |
||
|
Packet switching |
||
|
Compiling |
||
|
Routing |
QUESTION 3
One advantage of the stored-program concept is that a computer can easily return to a previous instruction and repeat it.
True
False
QUESTION 4
The PDP series of minicomputers were developed by IBM.
True
False
QUESTION 5
This person was given credit for developing the stored program concept
|
Alan Turing |
||
|
John Mauchly |
||
|
J. Presper Eckert |
||
|
John von Neumann |
In: Computer Science
From the MNIST dataset introduced in class, write code in Python that
a) Splits the 42000 training images into a training set (50% of all the data) and a test set (the rest). The labels should also be split accordingly. [10 points]
b) Use this training set for training a multi-class logistic regression model and test it on the test set. Report the score. [10 points]
c) Use this training set for training a multi-class support vector machine model and test it on the test set. Report the score.
In: Computer Science
Python
Pikachu is surrounded by pesky zubats! Will Pikachu be able to defeat all the bats, or will their numbers prove too great for our hero? You must write a program to answer this question. When your program starts, allow the user to input the number of zubats that are attacking Pikachu (you may assume the user enters a positive number). Then, you must simulate a series of battles between Pikachu and a zubat. Initially, Pikachu has 35 health, but he may lose health during the battles, and if he ever runs out of health, he faints! The zubats will attack one at a time, and the rules for the battle simulation are as follows. Note that you will definitely need to import Python’s random module, as there is luck in the simulation. • The zubat attacks rst. It has a 50% chance to hit Pikachu (Hint: Use the random() function to generate a random float between 0 and 1, then check if that oat is less than 0.5). If the zubat hits, it will randomly deal either 1, 2, or 3 damage to Pikachu. • Then Pikachu attacks. Pikachu has a 60% chance to hit the zubat. If he does, he will defeat the bat. The bats will attack in turn until either they are all defeated, or Pikachu faints. When that happens, print out a message that describes the outcome. • If Pikachu defeated all the zubats, print out that he triumped and how much health he has left • If Pikachu fainted, print out how many of the zubats he managed to defeat.
First, write a function to simulate a single battle between Pikachu and one zubat. Pikachu’s current health should be a parameter to this function, and the function should return the amount of health Pikachu has remaining after the battle is over. Make sure this function is working before going on! Put print() statements into your function to print out intermediate values during the battle to see if they make sense. You’ll take these print() statements out later (the sample output above doesn’t have them), but they’re invaluable for testing your function.
Second, in the “main” part of your Python program, use console input to ask the user for the number of zubats. You can assume the user will enter a positive integer. Then, use a loop to keep calling your function from Step 1 so long as there are still zubats to defeat and Pikachu hasn’t fainted. Once the loop is done, display the outcome to the console as per the sample output shown above.
In: Computer Science
Write a program that dynamically allocates a built-in array large enough to hold a user-defined number of test scores. (Ask the user how many grades will be entered and use a dynamic array to store the numbers.) Once all the scores are entered, the array should be passed to a function that calculates the average score. The program should display the scores and average. Use pointer notation rather than array notation whenever possible. (Input Validation: Do not accept negative numbers for test scores.) Make it a class, call it something like gradeholder. You will need a destructor because you are using dynamic arrays.
please help!! this is C++ programming fundamental 2 and this is visual studio, thank you!
In: Computer Science
Okay so I already completed steps A - C listapi is now a library for project 4 the trouble I am having is how to do part D.
Use ListAPI as a library.
a) Create a Intellij project and name it “p4_2_your-id”.
b) Create a JAR file of “ListAPI”.
Download “ListAPI.zip” from Moodle and extract the NetBeans project folder “ListAPI” from the archive file.
In NetBeans, open “ListAPI”. Under the Project tab, right click on ListAPI and select Clean. Under the Project tab, right click on ListAPI and select Build. The created jar file is in “dist” folder.
Move the JAR file to the folder that contains your project folder. Navigate to the “ListAPI” NetBeans project folder and open it. Open the folder “dist”. Copy the file “ListAPI.jar” and paste it in the same folder that contains the “p5_2_your-id” project folder.
c) Attach the “ListAPI.jar” to your project.
Under the NetBeans Project tab, open the project created in step (a).
Right click on Libraries and select “Add JAR/Folder...”, and then navigate to “ListAPI.jar”. In the Add JAR/Folder dialog box, select “ListAPI.jar”, select Relative Path (which, if you have followed the preceding instructions, will be “../ListAPI.jar”) and click OK.
The classes in the JAR file are now available either by adding the following import statement to classes in your project
import listapi.*;
or by entering the full name of a class as in the following example.
listapi.TestGenericQueue tgq
= new listapi.TestGenericQueue();
d) In your project “p4_2_your-id”, add code to enqueue 5 integer values in a listapi.GenericQueue, displaying the queue as each value is added. Then, dequeue each element in the queue, adding each value to a listapi.GenericStack, displaying the queue and stack as each value is moved from the stack to the queue. Finally, pop all values of the stack and add them to a listapi.MyArrayList, displaying the stack and the list as each value is moved from the stack to the list.
In: Computer Science
Write the pseudo code for longest common subsequence algorithm in Java.
Alg lCS( X , n, Y, m)
Input: String X of length n, String Y of length m
Output: return the length of the longest common subsequence between X and Y
In: Computer Science
1) Suppose we have the following IP addresses for two different organizations, we have to create 5 networks having 30 hosts in it. Find first sub network ID, Fist address, Last address and Broadcast for each of the following given addresses?
a) 14.23.120.8
b) 252.5.15.111
In: Computer Science
Utilizing PHP and HTML code
Create a form that has text inputs for two numbers and a submit button. Submit the values to a program that calculates and displays the GCD of the two numbers. The greatest common divisor of two integers a and b is the largest integer that is a factor of both a and b.
The GCD of any number and 1 is 1, and the GCD of any number and 0 is that number.
For example:
gcd(24, 84) =12,
gcd(105, 45) =15,
gcd(409, 1) = 1,
and gcd(0, 8) =8.
You could set up a loop for each number and find all the factors using the modulo operator. Then you could compare the two lists of factors and find the largest number they have in common. This would work but it is going to be slow for very large numbers.
One efficient way to compute the GCD is to use Euclid's Algorithm, which states the following:
gcd(a, b) = gcd(b, a % b)
gcd(a, 0) = Absolute value of a
Here is an example of using this algorithm for 154,320 and 4,320
Looks like it would be perfect for a while loop.
In: Computer Science
I need to make pseudo code for hybrid priority
queue using both minheap and maxheap by ARRAY.
i need to have a function that extends the size of array once it
meets certain condition.
Also, I need to implement function remove, insert(k,v), top,
toggle, switchtoMin, switchtoMax, state, isEmpty, and size.
Please guide me the pseudo code with above conditions
In: Computer Science
This is for c++
Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types.
For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be:
from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array of the associated flowrate)
a series of values and the square roots of those integers (an int array of values and a double array of associated square roots)
a series of values and an indication of whether or not each value is odd or even (an int array and a bool array)
1. Declare and initialize a constant to represent the size of both arrays (at least 10 positions)
2. Declare and initialize your first array
3. Declare and initialize your second array, based on the data in your first array
4. Output the contents of both arrays in neat columns with headers
Optional suggestions (good to do, not required)
1. Try to break your program up into different functions
2. Use user input to initialize the first array
In: Computer Science
Write an MPI program that implements the hypercube bitonic sort algorithm. The program should be tested using a sequence of 64 integers (from 1 to 64, initially not sorted) and 8 processes. The number of elements assigned to each process is 8.
In: Computer Science
In: Computer Science