Hello! I'm trying to work on a python lab in my class, and we basically have to make this method
play_interactive
Now for the fun bit. The function play_interactive will take just one argument --- the length of patterns to use as keys in the dictionary --- and will start an interactive game session, reading either '1' or '2' from the player as guesses, using the functions you wrote above and producing output as shown in the sample game session at the beginning of this writeup. If the player types in any other input (besides '1' or '2'), the game should terminate.
Hint: the input function can be used to read input from the user as a string.
My code so far looks like this, I have the basic loop down and
working, but my guesses list to retain the guesses for this method
isn't updating
def play_interactive(pattern_length=4):
while True:
x = input()
intX = int(x)
guesses = ([])
if(intX == 1 or intX == 2):
guesses.append(intX)
print(len(guesses))
else:
print("Finished")
break
Any help would be appreciated! Thank you so much
In: Computer Science
using C program
Assignment
Write a computer program that converts a time provided in hours, minutes, and seconds to seconds
Functional requirements
Nonfunctional requirements
Sample run
4 hours, 13 minutes and 20 seconds is equal to 15200 seconds. 8 hours, 0 minutes and 0 seconds is equal to 28800 seconds. 1 hours, 30 minutes and 0 seconds is equal to 5400 seconds.
Grading
This assignment will be graded according to the programming grading rubric.
Due date
The assignment is due by the 11:59pm on September 20, 2019.
Requested files
time_to_sec.c
/*
* time_to_sec.c
*
* Created on: Jul 20, 2016
* Author: leune
*/
// appropriate #include statements
/* Convert a time interval specified in hours, minutes and seconds to
* seconds.
* Parameters:
* hours, minutes, seconds: input time elements
* Preconditions:
* 0 <= minutes < 60
* 0 <= seconds < 60
* Return:
* number of seconds in the interval
*/
unsigned int time_to_sec(unsigned int hours, unsigned int minutes,
unsigned int seconds) {
// complete this
}
/* Print a formatted representation of the calculation
* Parameters:
* hours, minutes, seconds: input time elements
* Postcondition:
* Function will write the calculation to standard output.
*/
void format_seconds(unsigned int hours, unsigned int minutes,
unsigned int seconds) {
// complete this
}
int main(void) {
format_seconds(4, 13, 20);
format_seconds(8, 0, 0);
format_seconds(1, 30, 0);
}
In: Computer Science
Create a 1- to 2-page IRP Microsoft Word for an IT organization. In your plan, ensure you:
In: Computer Science
C++
Given two finite sets, list all elements in the Cartesian product of these two sets.
In: Computer Science
Computer Science (C and Assembly Languages)
• Assume there are two 32-bit variables in RAM memory called In and Out. Write C code that sets Out equal to In plus 2.
• Assume there are two 32-bit variables in RAM memory called In and Out. Write assembly code that sets Out equal to In plus 2.
• What are the three stack rules?
• Assume B1 is a 32-bit unsigned global variable. We wish to write code that decrements B1 with the exception that it will not decrement if B1 is already 0. Draw a flowchart of the process. Write the code in both C and assembly.
• Assume G1 is a 32-bit unsigned global
variable. We wish to write code that increments G1 if G1 is less
than 20. Draw a flowchart of the process. Write the code in both C
and assembly.
• Develop the pseudocode and the flowchart for a program that finds the sum of 5 numbers.
• Comment each line of the ARM Assembly
language to explain what the code does. [4 pts]
start
MOV r0, #15
MOV r1, #8
ADD r0, r0, r1
MOV r4, #0x300
• Comment each line of the C language
to explain what the code does. [4 pts]
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);
if (number < 0)
{
printf("You entered %d.\n", number);
}
printf("The if statement is easy.");
return 0;
}
In: Computer Science
Python
Albert Einstein famously said that compound interest is the 8th wonder of the world. Hopefully, all of you have had a finance course to teach you why it is so much more powerful than simple interest, which we programmed in class. If you are unfamiliar with compound interest, google it (note - if you google "compound interest for dummies" you will get a MUCH simpler explanation of how it works, without greek function notations!!)
Your assignment this week is to use a for loop, with the range() function to figure out compound interest on a deposit. You will ask the user for the amount of the deposit, the interest rate and the number of years and tell her how much money she has after that amount of time. Be sure to use the isnumeric function, and do NOT use an exponent to figure out compound interest - use a loop!
In: Computer Science
Q4: Write a program that takes as input two opposite corners of a rectangle: (x1,y1) and (x2,y2). Finally, the user is prompted for the coordinates of a third point (x,y). The program should print Boolean value True or False based on whether the point (x,y) lies inside the rectangle. If the point lies on the rectangle, the program should print False.
Program should work irrespective of the order in which the user inputs the opposite coordinates. program user should be able to input coordinates in all possible orders.
- Right upper coordinate first and then left lower coordinate
- Left lower coordinate first and then right upper coordinate
- Left upper coordinate first and then right lower coordinate
- Right lower coordinate first and then left upper coordinate
In: Computer Science
I need to update this java program to take input about each employee from a file and write their information and salary/pay information to a file. use input file
payroll.txt
Kevin
Yang
60
20
Trey
Adams
30
15
Rick
Johnson
45
10
Cynthia
Wheeler
55
11.50
Sarah
Davis
24
10
Muhammad
Rabish
66
12
Dale
Allen
11
18
Andrew
Jimenez
80
15
import java.util.Scanner;
public class SalaryCalcLoop
{
double Rpay = 0, Opay = 0;
void calPay(double hours, double rate) {
if (hours <= 40)
{
Rpay = hours * rate;
Opay = 0;
}
else
{
double Rhr, Ohr;
Rhr = 40;
Ohr = hours - Rhr;
Rpay = Rhr * rate;
Opay = Ohr * (1.5 * rate);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name;
int shift = 0;
Double rate, hours;
System.out.println("Pay Calculator");
String ch = "";
do
{
System.out.println("Enter Your Name");
name = sc.next();
System.out.println("Enter Your Shift, Enter 0 for Day, Enterv1 for
Night");
System.out.println("0=Day, 1= Night");
shift=sc.nextInt();
System.out.println("Enter Number of Hours Worked");
hours = sc.nextDouble();
System.out.println("Enter Hourly Pay");
rate = sc.nextDouble();
SalaryCalc c = new SalaryCalc();
c.calPay(hours, rate);
Double Tpay = c.Rpay + c.Opay;
System.out.println();
System.out.println("Calculate Pay");
System.out.println("Employee Name: " + name);
System.out.println("Employee Regular Pay: " + c.Rpay);
System.out.println("Employee Overtime Pay: " + c.Opay);
System.out.println("Employee Total Pay: " + Tpay);
if (shift == 0)
{
System.out.println("Employee PayPeriod is Friday");
}
else
{
System.out.println("Employee PayPeriod is Saturday");
}
System.out.println("Press Y to continue. Press any other key to
exit ");
ch=sc.next();
}
while(ch.equalsIgnoreCase("y"));
}
}
Saturday"); } System.out.println("Press Y to continue. Press any other key to exit "); ch=sc.next(); } while(ch.equalsIgnoreCase("y")); } }
In: Computer Science
Write a class encapsulating the concept of a Student Employee, assuming that a student has the following attributes: last name, first name, id, array of hours worked weekly. Include a constructor, the accessors and mutators, and method toString. Also code the following methods: one returning the average weekly hours and a method to add the hours to the array of hoursWorked (this means creating a large array). Let this array store the weekly hours (not daily hours) worked for each student employee. Write a client class to create 2 student objects and test all your methods.
I've been working for a few days and I'm not sure why I can't figure it out.
Please show using only import.java.util.Scanner/ import java.io.*; Thank you.
In: Computer Science
1. Using Induction on the length of derivations, prove that the set of all Primitive Recursive Functions (PR) is a subset of all Partial Computable Functions (P).
2. Using the preceding problem, conclude that the set of all Primitive Recursive Functions (PR) is a subset of all Computable Functions (R).
In: Computer Science
1. Suppose you are implementing software to be used in a handheld device that checks whether event attendees are part of a group of people allowed access to a special session at the event. Guests can purchase access to the special session any time up to the instant the event begins, and the device receives updated records to ensure paying guests (only) are allowed in to the special session Would choosing a set data structure to manage the special session guests or a list be more efficient? Explain
In: Computer Science
using MIPs assembly, ask the user to enter two numbers. Then multiply the two numbers using bit shifting (not 'mul'). This should work multiplying 2 positive numbers, 2 negative numbers, and a positive/negative number.
Then output the result and ask user if he/she has more calculations to complete.
In: Computer Science
In: Computer Science
Respond to the following in a minimum of 175 words:
Discuss the wireless spectrum and how it relates to a wireless network. What frequency ranges, or bands, are associated with wi-fi use? How does wi-fi transmission differ from data transmission over a physical network? How might that difference affect data security over a wi-fi network?
In: Computer Science
Two Systems 80 Km apart are communicating through a direct Metallic cable (note: signal speed is 2 x 10^8 m/s). The data is in the form of 60 KB packets with transmission rate 1M bps. Calculate the following:
In: Computer Science