In the funcs directory create a file named funcs.py. This section requires that you implement and test multiple functions. You should develop these functions and their tests one at a time. The function implementations must be placed in funcs.py. The test cases will, of course, be placed in the provided funcs_tests.py.
You must provide at least two test cases for each of these functions. In addition, you should separate your testing into multiple functions (the file includes stubs for the first two testing functions to get you started).
This part will be executed with: python funcs_tests.py
f(x) = 7x2 + 2x
Write a function, named f (a poor name, really, but maps from the context), that corresponds to the stated mathematical definition.
g(x, y) = x2 + y2
Write a function, named g (again, a poor name), that corresponds to the stated mathematical definition.
hypotenuse
Write a function, named hypotenuse, that takes two arguments corresponding to the lengths of the sides adjacent to the right angle of a right-triangle and that returns the hypotenuse of the triangle. You will need to use the math.sqrt function from the math library, so be sure to import math at the top of your source file.
is_positive
Write a function, named is_positive, that takes a single number as an argument and that returns True when the argument is positive and False otherwise. You must write this function using a relational operator and without using any sort of conditional (i.e., if); the solution without a conditional is actually much simpler than one with. Your test cases should use assertTrue and assertFalse as appropriate.
NOTE:All of the files said to be provided are just templates for the solution but are not needed to do the problem
In: Computer Science
[JAVA SCRIPT]
Please create an array of student names and another array of student grades.
Create a function that can put a name and a grade to the arrays.
Keep Read student name and grade until student name is “???”. And save the reading by using a function
Create another function to show all the grade in that object.
Create the third function that can display the maximum grade and the student’s name.
Create a sorting function that can sort the arrays based on the student’s grade.
Display all the grades and names sorted by the grade.
In: Computer Science
Python file
def calci(): grade = float(input("Enter your grade:")) while (grade <= 4): if (grade >= 0.00 and grade <= 0.67): print("F") break elif (grade >= 0.67 and grade <= 0.99): print("D-") break elif (grade >= 1.00 and grade <= 1.32): print("D") break elif (grade >= 1.33 and grade <= 1.66): print("D+") break elif (grade >= 1.67 and grade <= 1.99): print("C-") break elif (grade >= 2.00 and grade <= 2.32): print("C") break elif (grade >= 2.33 and grade <= 2.66): print("C+") break elif (grade >= 2.67 and grade <= 2.99): print("B-") break elif (grade >= 3.00 and grade <= 3.32): print("B") break elif (grade >= 3.33 and grade <= 3.66): print("B+") elif (grade >= 3.67 and grade <= 3.99): print("A-") break elif (grade == 4.00): print("A") break elif (grade == 4.00): print("A+") else: print("Invalid input enter FLOAT only") def main2(): question = input("Continue (y/n)") if question == "y" or question == "Y": calci() if question == "n" or question == "N": print("Bye") print("ISQA 4900 quiz") main2() TWO PROBLEM1)it need to ask question everytime 2) it should show an invalid message
In: Computer Science
I need to create a monthly loan Calculator in C++. I know the formula but can't figure out what's wrong with my code. Any clarification would be appreciated!
// Only add code where indicated by the comments.
// Do not modify any other code.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
// ---------------- Add code here
--------------------
// -- Declare necessary variables
here
--
int years = 0; //n
int LoanAmount = 0;
double AnnualRate = 0.0; //r
double payment = 0.0;
// --
cout << "Enter the amount, rate as a
percentage (e.g. 3.25), and number of years\n";
cout << " separated by spaces: " <<
endl;
// ---------------- Add code here
--------------------
// -- Receive input and compute the monthly payment
--
cin >> LoanAmount >> AnnualRate >>
years;
AnnualRate = AnnualRate / 100;
years = years * 12;
payment = ((LoanAmount * AnnualRate) / 1 - (1 +
AnnualRate) * -years);
// ---------------- Add code here
------------------
// Print out the answer as a double, all by
itself
// (no text) followed by a newline
// Ex. cout << payment << endl;
cout << payment << endl;
return 0;
}
In: Computer Science
Develop a C program for matrix multiplication focusing on using malloc and pointers WITHOUT USING BRACKETS [] !!
* DO not use [ ] 'brackets', focus on using malloc, calloc, etc...
Program will ask user for the name of the text file to be
read
Read the datafile with format:
1
2
1
1 2
3
4
So the first three lines will represent m, n, p (Matrix A: m x n
||| Matrix B: n x p), follwing are the two matrices.
Representing:
A = |1 2| B = |3|
|4|
------------------------------------------------
example input and output:
Matrix A contents:
1 2
3 4
5 6
Matrix B contents:
7 8
9 10
11 12 13 14
Matrix A * B is:
29 32 35 38
65 72 79 86
101 112 123 134
The datafile read for this example is:
3
2
4
1 2
3 4
5 6
7 8 9 10
11 12 13 14
In: Computer Science
Specification
This script reads in class data from a file and creates a
dictionary.
It then prints the data from the dictionary.
The script has the following functions
class_tuple_create
This function has the following header
def class_tuple_create(filename):
The function reads in a file with four fields of data about a
class.
The fields are
Course ID Room number Instructor Start time
The function must print an error message if the file cannot be
opened for any reason.
The function should read in each line of the file and split it into
a list of 4 elements.
It should add the information in the line into a dictionary, where
the key is the course number and the value is a tuple consisting of
the room number, the instructor and the start time.
The function should return this dictionary when it has read all the
lines in the file.
print_classes
This function has the following header
def print_classes(class_info):
It should print the following table header
ID Room Instr Start
Then it should print out the data for each class in alphabetical
order by Class ID.
The data for each course should align with the labels.
Test Code
The script must contain the following test code at the bottom of the file
class_information = class_tuple_create('xxxxx')
class_information = class_tuple_create('courses.txt')
print_classes(class_information)
For the test code to work you must copy into your hw3 directory the file from /home/ghoffman/course_files/it117_files.
cp /home/ghoffman/course_files/it117_files/courses.txt .
Suggestions
Write this script in stages, testing your script at each step
Output
The output should look something like this
Error: Unable to open xxxxx ID Room Instr Start ------------------------------- CM241 1411 Lee 13:00 CS101 3004 Haynes 8:00 CS102 4501 Smith 9:00 CS103 6755 Rich 10:00 NT110 1244 Burke 11:00
In: Computer Science
Implement an infix expression to postfix expression convertor in C++.
Note: - Support +, -, *, /, ( and ) in infix expressions.
- Operands will be nonnegative only.
- Assume infix expressions are valid and well formatted (one blank space to separate operand/operator)
For example,
- 3 * 4 + 5 ➔ 3 4 * 5 +
- 3 + 4 * 5 ➔ 3 4 5 * +
- (3 + 4) * (5 + 6) ➔ 3 4 + 5 6 + *
In: Computer Science
Write a C# console program that continually asks the user "Do you want to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and then get keyboard input of the name. After entering the name, display the name to the screen.
In: Computer Science
Describe how cloud computing may lead to “intelligent fabrics” in the future and how this will impact companies and consumers. Use real-world examples to support your assertions.
In: Computer Science
Write a C# console program that continually asks the user "Do you want to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and then get keyboard input of the name. After entering the name, display the name to the screen.
In: Computer Science
Linux Fundamentals part 4 final Below are questions related to the command line use of Linux. You can use the videos, man pages, and notes to answer these questions. Remember that Linux is CASE SENSITIVE. Rm and rm are NOT the same command. I will count off totally for a question if you do not take this into account. For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. I want the entire command sequence.
16. Find all files under ~ whose content contain the keyword taco OR Taco OR taCo OR tacO. NOT all variations in case for 'taco', but just the variations listed meaning a keyword of tAco, tACO, tACo, etc, will not produce a result.
17. Find all files under the current directory which ends in
'.txt' (just the .txt not the single quotes) and use -exec to
create a listing of each files inode number. Since we're using
-exec, this means we will call another command to produce the inode
based on the results found. What command do we use to make
listings? Now you just need to find how to make it produce an inode
result. To the man page!
18. What command would I run to update the database of file
names used by the locate command?
19. Find all files under the /var directory with a size less
than 1 kilobyte. Use -exec and an appropriate command to copy those
files to ~/Documents/FallFun/sep.
20. Find all files under the ~ directory that are named
'Picard' ignoring case.
In: Computer Science
Prove that the following language are NOT regular using the pumping lemma
(20 pt.) ? = {? ∈ {?, #}∗ | ? = ??#??# ... #?? ??? ? ≥ ?, ?? ∈
?∗ ??? ????? ?, ??? ?? ≠?? ???????? ?≠?}
Hint: choose a string ? ∈ ? that contains ? #’s.
In: Computer Science
implement Max Subarray Problem via Divide-and-conquer off this code
#include <iostream>
#define MAX_INT 2147483647
using namespace std;
int main(int argc,char **argv) {
int* array;
int arraySize = 1;
// Get the size of the sequence
cin >> arraySize;
array = new int[arraySize];
// Read the sequence
for(int i=0; i<arraySize; i++){
cin >> array[i];
}
In: Computer Science
Configuring Windows Firewall
In this project, you edit configuration settings on Windows Firewall.
Note
Windows Firewall uses three different profiles: domain (when the computer is connected to a Windows domain), private (when connected to a private network, such as a work or home network), and public (used when connected to a public network, such as a public Wi-Fi). A computer may use multiple profiles, so that a business laptop computer may use the domain profile at work, the private profile when connected to the home network, and the public profile when connected to a public Wi-Fi network. Windows asks whether a network is public or private when you first connect to it.
1
Click Start, click the search icon, and enter Firewall.
2
Click Windows Firewall Control panel.
3
Click Turn Windows Firewall on or off. Be sure that the Windows Firewall is turned on for both private and public networks.
4
Under Public network settings check Block all incoming connections, including those in the list of allowed apps. This provides an extra level of security when using a public network such as a free Wi-Fi network by preventing a malicious incoming connection from another computer on the network. Click OK.
5
To allow an inbound connection from an installed application, in the left pane click Allow an app or feature through Windows Firewall.
6
Each program or feature of Windows can be chosen to allow an incoming connection on public or private networks. Click Allow another app.
7
From here you can select an app that will permit an incoming connection. Because this is a security risk, click Cancel and then OK.
8
Now check the configuration properties of Windows Firewall. Click Advanced settings.
9
Click Properties in the right pane.
10
Note the settings on each of the profiles by clicking the Domain Profile, Private Profile, and Public Profile tabs. Is there any difference in the settings between these profiles? Why?
11
On each tab under Settings, click Customize. Be sure that Display a notification is set to Yes. Why would this be important?
12
Click OK to return to the Windows Firewall with Advanced Security page.
13
In addition to being application-aware, Windows Firewall also can be configured for firewall rules. Click Outbound Rules in the left pane to block a program from reaching the Internet.
14
In the right pane, click New Rule.
15
Click Port and then click Next.
Note
In addition to ports, the Windows Firewall also can block by program (Program) or even by program, port, and IP address (Custom).
16
If necessary, click TCP.
17
Next to Specific remote ports: enter 80. Click Next.
18
If necessary, click Block the connection. Click Next.
19
Be sure that this new rule applies to all three domains. Click Next.
20
Under Name: enter Blocking Port 80. Click Finish.
21
Now open a web browser and try to connect to the Internet. What happens?
22
Click the Back button to return to the Windows Firewall screen and click Action and Restore Default Policy to disable this rule. If a warning dialog box appears, click Yes. Click OK.
23
Select Outbound Rules in the left pane. In the right pane, click New Rule.
24
Click Custom and Next.
25
If necessary, click All programs and Next.
26
Note that you can configure a firewall rule based on protocol, protocol number, local port, and remote port.
27
Click Cancel.
28
Close all windows.
please answer all the questions, and take screenshots of all the steps
In: Computer Science
What is printed?
public static void main(String[] args)
{
int i = 6;
aMeth(i);
System.out.print(i);
}
public static void aMeth(int i)
{
System.out.print(i);
i = i + 1;
System.out.print(i);
}
2)
What is printed as the value of b?
Scanner kybd = new Scanner(System.in);
System.out.println("Enter two ints " );
int i = kybd.nextInt();
int j = kybd.nextInt();
boolean b = ((i % 2) == 0) && ((j % 2) == 0);
System.out.println(b);
3)
In: Computer Science