Python 2.7
In Rock Paper Scissors game, try below task (and also using below statements as much as you can):
- %s in print statements
- \n or \t in print statements
- run 100 times of RPS game simulation between two computers and print results for # of ties.
- in your program, allow user to decide how many game to play.
- allow program to suggest user to retype RPS if there's any typos
In: Computer Science
write the MATLAB code for: Let ? = sin2 (?) and ? = sin(?) cos(?). Let x vary from 0 to 10? in increments of 0.1?. Plot two figures part a & b. This panel has rows, one figure per row. a. Plot x versus y. This plot is on the top of panel and the next figure (part b) is at bottom of panel. i. Give a meaningful title to this figure. ii. x-axis is time with unit of s. y-axis is voltage with unit of V. Label both x- and yaxis. iii. Add a legend to the graph. b. Plot x versus z. This figure is at bottom row. i. Give a meaningful title on graph. ii. Label x-axis is time with unit of s. y-axis is voltage with unit of V. Label both xand y- axis. iii. Change the thickness of this curve. Use any value other than default value. iv. Change curve to red dashed curve. v. Add a legend to the graph.
In: Computer Science
Write a complete ARM asembly program for following code:
g=12, h=8, i=2, j=5;
f = (g + h) - (i + j);
Your program displays the message:
f = (g + h) – (i + j) = 13
Note that 13 should be calculated, not hardcoded
Below is my current code:
.global _start
_start:
mov R0,#12
mov R1,#8
mov R2,#2
mov R3,#5
add R4,R0,R1
add R5,R2,R3
sub R6,R4,R5
How should I display the message: "f = (g + h) – (i + j) ="? And my code keeps giving me "Bad instruction" errors? How can I fix it?
In: Computer Science
In: Computer Science
I need assistance on this problem in Pseudocode and in C++ Program
1: Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame. For this program, imagine we want to track an object and detect if it goes off the left or right side of the screen (that is, it’s X position is less than 0 and greater than the width of the screen, say, 100). Write a program that asks the user for the starting X and Y position of the object as well as the starting X and Y velocity, then prints out its position each frame until the object moves off of the screen. Design (pseudocode) and implement (source code) for this program.
Sample run 1:
Enter the starting X position: 50
Enter the starting Y position: 50
Enter the starting X velocity: 4.7
Enter the starting Y velocity: 2
X:50 Y:50
X:54.7 Y:52
X:59.4 Y:54
X:64.1 Y:56
X:68.8 Y:58
X:73.5 Y:60
X:78.2 Y:62
X:82.9 Y:64
X:87.6 Y:66
X:92.3 Y:68
X:97 Y:70
X:101.7 Y:72
Sample run 2:
Enter the starting X position: 20
Enter the starting Y position: 45
Enter the starting X velocity: -3.7
Enter the starting Y velocity:
11.2 X:20 Y:45
X:16.3 Y:56.2
X:12.6 Y:67.4
X:8.9 Y:78.6
X:5.2 Y:89
.8 X:1.5 Y:101
X:-2.2 Y:112.2
This assignment is about Repetition Structures.
For Pseudocode, here are key words to use
: · DO … WHILE – A loop that will always run at least once ·
FOR … ENDFOR – A loop that runs until certain criteria is met ·
WHILE … ENDWHILE – A loop that runs only while certain criteria is met ·
FOREACH … ENDFOREACH – A loop that runs over elements in a data structure · BREAK - "break out" of the current loop (or other structure) you're in and start immediately after the loop · CONTINUE - skip over the current iteration of the loop and move on to the next one
In: Computer Science
I want c++ /c program to build a double linked list and find with a function the middle element and its position and the linked list must be inserted by the user aand note You should handle the both cases of whether the size of the list even or odd
In: Computer Science
create a program that outputs a picture that represents halloween in ascii art (jack-o-lantern, witch's hat, etc)
ASSEMBLY LANGUAGE PROGRAM
In: Computer Science
what rcf4 key value k will reverse the s value the enteries of s will be equal to values from 255 to 0 in descending order
In: Computer Science
1.) Many languages (e.g., C and Java) distinguish the character ’c’ from the string “c” with separate sets of quotation marks. Others (e.g., Python) use “c” for both single characters and strings of length one. Provide (and justify) one advantage and one disadvantage of Python’s approach.
2.The designers of Java distinguish the primitive types (scalars) from the reference types (all other types of values) in the language. Discuss the costs and benefits to the programmer of this decision
3.In Ruby, the Hash class accepts the “each” method, allowing hashes to be interacted over, like a collection. In Java, however, the Map classes are not formally part of the JCF (Java Collections Framework). For both Ruby and Java, provide (and justify) an advantage of the language’s choice of location in the class hierarchy of its form of associative list
4.What are the basic differences, if any, in how Java and Ruby handle information hiding (a.k.a. encapsulation)?
5. Java and C++ support generic collections with type parameters, whereas Ruby does not. Does that fact place the Ruby programmer at a disadvantage? Why or why not?
In: Computer Science
//draft to work from for Assignment 7 where you compute a student's quiz average, dropping two lowest scores, assuming //they have 2 or more quizzes // a max of 12 quizzes can be taken #include <iostream> #include <iomanip> #include <cstdlib> #include <fstream> using namespace std; const int NUM_QUIZZES = 12; //assume 12 quizzes max can be taken int buildQuizArray( int [] ); //you need to write these 5 functions below void printQuizArray( string, int [], int ); double calcQuizAverage( int [], int ); void sortQuizArray( int [], int ); void copyArray( int [], int [], int ); int main() { //this is the driver code in main routine , calling your functions int quizArray[NUM_QUIZZES]; //declare array to hold 12 quizzes int numQuizzes; //will be filled in with number of quizzes from buildQuizArray numQuizzes = buildQuizArray( quizArray ); //call buildQuiz array, numQuizzes is returned from function printQuizArray( "Quiz Scores From QuizArray After My Build Function", quizArray, numQuizzes ); //print it out to make sure it is built correctly //take out when finished cout << fixed << setprecision(2); cout << endl << "Your quiz average is " << calcQuizAverage(quizArray, numQuizzes) << "%" << endl; //call function and get a double returned to print to user printQuizArray( "Quiz Scores From QuizArray after calling calcQuizAverage", quizArray, numQuizzes ); //print array again to make sure you did not change the original array return 0; } //******************************************************************************** int buildQuizArray( int array[] ) { //build the array of quizzes and return the count of entries of the array back to main routine } //************************************************************************* void printQuizArray( string reportTitle, int array[], int numValues ) { //print out the quiz array with appropriate title passed to you in reportTitle....add "/10" to end of each quiz score } //*************************************************************************** double calcQuizAverage( int array[], int numValues ) { //if 2 or less values in array use formula in assignment sheet for 2 or less values to compute average //if more than 2, define another "work" array in this function, call copyArray function below to copy elements to a "work array" from array passed to you, //and then call sortQuizArray function to sort your "work array". After work array has been sorted ascending order, use formula in sheet // to compute the quiz average (which will not factor in the two lowest quiz scores in positions 0 and 1 in array) //return the average computed to the main return } //*********************************************************** void copyArray( int destinationArr[], int sourceArr[], int numValues ) { //copy the data from source array into destination array with a loop // numValues has number of entries in the array //at the bottom of this function print out destinationArr to make sure it is correctly copied, simply call printQuizArray printQuizArray("Here's my copy/work array that is to be sorted: ", destinationArr ,numValues); } //*************************************************************** void sortQuizArray( int array[], int numValues ) { //code selection sort logic here to sort array passed in , BEGIN=0, END=numValues-1 //suggestion: document each line of code here to simulate the selection sort algorithm //at bottom of sort, to make sure table is sorted call print function and verify it is sorted printQuizArray( "Here is my sorted array", array, numValues ); //print it out to make sure it is built correctly,take out when finished }
In: Computer Science
Using Java,
Ask for the runner’s name
Ask the runner to enter a floating point number for the number of miles ran, like 3.6 or 9.5
Then ask for the number of hours, minutes, and seconds it took to run
A marathon is 26.219 miles
Pace is how long it takes in minutes and seconds to run
1 mile.
Example Input:
What is your first name? // user enters Pheidippides
How far did you run today? 10.6 // user enters 10.6
miles
How long did it take? Hours: 1 // user enters 1 hours
Minutes: 34 // user enters 34 minutes
Seconds: 17 // user enters 17 seconds
Example Output:
Hi Pheidippides
Your pace is 8:53 (minutes: seconds)
At this rate your marathon time would be 3:53:12
Good luck with your training!
After your program tells the user what their pace is,
your program will build a table showing the following columns. The
pace table should start with the fastest man time which is Eliud
Kipchoge.
Example:
Pace Table
Pace Marathon
4:37 2:01:04 ←- Eliud Kipchoge
5:17 2:18:41
5:57 2:36:18
6:37 2:53:55
7:18 3:11:32
7:58 3:29:09
8:38 3:46:46
8:53 3:53:12 ← Pheidippides
The table should start with the World Record pace and time which is 4:37, 2:01:04.
Then continues in 17 minute and 37 second intervals until you reach the marathon time of the user.
Use a static function to print the pace table, introduce a while loop.
For the first person it should call a printTable function
Example : printTable (pace, “<--- Eliud Kipchoge”) something like that
The pace table continues until it reaches the user
printTable (myPace, name) something like that
For the marathon and pace time, make sure the format has 0’s if the time is 9 seconds, it should be 09.
Use the printf statement for formatting output (“02d %f%s”)
In: Computer Science
Python Programming: Scrambled Word Game
Topics: List, tuple
Write a scrambled word game. The game starts by loading a file containing scrambled word-answer pair separated. Sample of the file content is shown below. Once the pairs are loaded, it randomly picks a scrambled word and has the player guess it. The number of guesses is unlimited. When the user guesses the correct answer, it asks the user if he/she wants another scrambled word.
bta:bat
gstoh:ghost
entsrom:monster
Download scrambled.py (code featured below) and halloween.txt. The file scrambled.py already has the print_banner and the load_words functions. The function print_banner simply prints “scrambled” banner. The function load_words load the list of scrambled words-answer pairs from the file and return a tuple of two lists. The first list is the scrambled words and the second is the list of the answers. Your job is the complete the main function so that the game works as shown in the sample run.
Optional Challenge: The allowed number of guess is equal to the length of the word. Print hints such as based on the number of guess. If it’s the first guess, provides no hint. If it’s the second guess, provides the first letter of the answer. If it’s the third guess, provides the first and second letter of the correct answer. Also, make sure the same word is not select twice. Once all words have been used, the game should tell user that all words have been used and terminate.
Sample run:
__
_
_
_
/ _\ ___ _ __ __ _ _ __ ___ | |__ | | ___ __| |
\ \ / __|| '__|/ _` || '_ ` _ \ | '_ \ | | / _ \ / _` |
_\ \| (__ | | | (_| || | | | | || |_) || || __/| (_| |
\__/ \___||_| \__,_||_| |_| |_||_.__/ |_| \___| \__,_|
Scrambled word is: wbe
What is the word? bee
Wrong answer. Try again!
Scrambled word is: wbe
What is the word? web
You got it!
Another game? (Y/N):Y
Scrambled word is: meizob
What is the word? Zombie
You got it!
Another game? (Y/N):N
Bye!
Provided code (from scramble.py
def display_banner():
print("""
__
_
_
_
/ _\ ___ _ __ __ _ _ __ ___ | |__ | | ___ __| |
\ \ / __|| '__|/ _` || '_ ` _ \ | '_ \ | | / _ \ / _` |
_\ \| (__ | | | (_| || | | | | || |_) || || __/| (_| |
\__/ \___||_| \__,_||_| |_| |_||_.__/ |_| \___|
\__,_|
""")
def load_words(filename):
#load file containing scrambled word-answer
pairs.
#scrambled word and answer are sparated by :
scrambled_list = []
answer_list = []
with open(filename, 'r') as f:
for line in f:
(s,a) = line.strip().split(":")
scrambled_list += [s]
answer_list += [a]
return (scrambled_list, answer_list)
def main():
display_banner()
(scrambled_list, answer_list) =
load_words('halloween.txt')
#your code to make the game
work.
main()
Halloween.txt file.
bta:bat
gstoh:ghost
entsrom:monster
ihtcw:witch
meizob:zombie
enetskol:skeleton
rpamevi:vampire
wbe:web
isdepr:spider
umymm:mummy
rboom:broom
nhlwaeeol:Halloween
pkiumnp:pumpkin
kaoa jlern tcn:jack o lantern
tha:hat
claabck t:black cat
omno:moon
aurdclno:caluldron
In: Computer Science
Grettings,
thanks in advance
explain on this.
Discuss 5 reasons why people still prefer NAT (Network Address Translation) adoption rather than IPv6. ?
In: Computer Science
using java
Consider the following LinkedList that is composed of 4 nodes containing 13, 7, 24, 1. Assume that the Node.value is an int, and the reference to the first value is a Node called n. Write a method that computes the sum of all the values in the nodes of a linked list. For example, your method shall return the sum of all the nodes, in this example shall return 45
In: Computer Science
A full-time student pays $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next three years. Write a program with a loop that displays the projected semester tuition amount for the next three years. Also, provide the option to the student to calculate the tuition for another three years using the same percent increase. Please remember, if the student decides to calculate the tuition for another three years the starting tuition will be calculated tuition value for the end of the 3-year period.
CALCULATE USING PYTHON PROGRAMMING LANGUAGE. PLEASE INCLUDE NOTES AS WELL.
In: Computer Science