Question #1 Please specify he output of the following code (2.4) # import the pandas library and aliasing as pd import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(8, 4), index = ['a','b','c','d','e','f','g','h'], columns = ['A', 'B', 'C', 'D']) # for getting values with a boolean array print df.loc['a']>0
Question #2 Please specify the output of the following code (2.2)
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(5, 3), index=['a', 'c', 'e', 'f', 'h'],columns=['one', 'two', 'three']) df = df.reindex(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']) print df.dropna(axis=1)
Question #3 Given the following temp.csv (2.1)
S.No,Name,Age,City,Salary 1,Tom,28,Toronto,20000 2,Lee,32,HongKong,3000 3,Steven,43,Bay Area,8300 4,Ram,38,Hyderabad,3900
Please specify what is the output of the following code:
import pandas as pd df=pd.read_csv("temp.csv",names=['a','b','c','d','e'],header=0) print df
Question 4 Please describe what the following code is doing (2.3)
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(10, 4), index = pd.date_range('1/1/2000', periods=10), columns = ['A', 'B', 'C', 'D']) print df r = df.rolling(window=3,min_periods=1) print r['A'].aggregate(np.sum)
In: Computer Science
Comprehension and Coding 12. Nadha Skolar needs to write a method smallToBig() that will accept 3 integers as parameters and print out the sequence of numbers smallest to largest. For example, regardless of whether the sequence is 3 5 7, 5 7 3, 3 7 5, the method should print out 3 5 7. Nadha writes the following in IntelliJ and feels pretty confident until he submits the code to zyBooks… public static void smallToBig (int num1, int num2, int num3){ int min, middle, max; if (num1 <= num2){ min = num1; middle = num2; if (num1 <= num3) { middle = num1; max = num3; } else { middle = num3; max = num1; } } else { min = num2; middle = num1; if (num2 <= num3) { middle = num2; max = num3; } else { middle = num3; max = num2; } } System.out.println("Min = " + min + " Mid = " + middle + " Max = " + max); } Describe the error in Nadha’s program and how you could correct it. You do not have to code the fix
In: Computer Science
Research the topic of binary search trees. Write a brief summary of your understanding of this. Design a simple program, using pseudocode, that performs a search of a binary search tree.. In your own words, explain how a binary search tree works using graph theory terminology. Construct a binary search tree for any alphabetically ordered list of five words. Represent it visually as a graph. Discuss any characteristics you note about the graph you created in part (d). In your discussion, make sure to address the following: What are the degrees of each vertex? Is it a complete graph? Is the graph planar?
In: Computer Science
I need to make this into a Java Code:
Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate:
You must use π as defined in the java.lang.Math class.
Your prompt to the user to enter the number of days must be:
Enter radius:
Your output must be of the format:
Circle Circumference = circleCircumference
Circle Area = circleArea
Sphere Area = sphereArea
Sphere Volume = sphereVolume
Please make sure to end each line of output with a newline.
Please note that your class should be named CircleSphere.
In: Computer Science
Parameter Mystery. Consider the following program. List below the exact output produced by the above program (we do not claim that every line of output makes sense ;-).
public class Mystery
{ public static void main(String[] args)
{ String john = "skip";
String mary = "george";
String george = "mary";
String fun = "drive"; statement(george, mary, john);
statement(fun, "george", "work");
statement(mary, john, fun);
statement(george, "john", "dance"); }
public static void statement(String mary, String john, String fun)
{ System.out.println(john + " likes to " + fun + " with " + mary); } }
I know the output is
george likes to skip with mary george likes to work with drive skip likes to drive with george john likes to dance with mary
But I don't know why- can I get an explanation as to why???
In: Computer Science
#include <iostream>
#include <string>
using namespace std;
int main ()
{
//declarations
string name;
//input
cout <<"Enter your first name" << endl;
cin >> name;
//output
cout << "Hello " << name << "! " << endl;
return 0;
}
int age;
Add the following lines to your program:
cout << “Enter your age” << endl;
cin >> age;
Compile and Run.
What type is age? Describe this type.
float bodyTemp;
Add the lines to input and out your body temperature. Compile and run.
What type is bodyTemp? Describe this type.
Height (hint, use two variables)
Weight
Sex (hint, use the char type)
Last name
Answers to these questions only:
In: Computer Science
Give the value of x (x is an integer and assume integer arithmetic for all operations).
________ 1. x = 12 - 4 * 2 - 8;
________ 2. x = 24 / 2 + 1 * 4;
________ 3. x = 12 - 9 + 4 * 2 + 3 ^ 4;
________ 4. x = 24/(3 + 2) * 4;
________ 5. x = 2 * (5 - 3) + 7;
________ 6. x = 12 - (15/5 - 2) * 5;
________ 7. x = 20 - 15/((5 - 2) * 5);
________ 8. x = 13 % 5;
Evaluate the following equations, given A = 12, B = 3, C = 6, D = 2 ,A, B, C, and D are integers, and all operations are integer
________ 9. x = A + B/C - D^2.;
________ 10. x = A + B/(C - D^2);
________ 11. x = (A + B) % C;
________ 12. x = (A + B)/C - D^2;
Assume the following order of operations:
!
&&
||
Give the value of x,
given A = FALSE, B = FALSE, C = FALSE, D = TRUE. E = 10, F = 15
________ 13. x = A && B
________ 14. x = C || D
________ 15. x = !C
________ 16. x = !(A && D)
________ 17. x = !C && B
________ 18. x = ( E < 10) && (E == F)
________ 19. x = A && B || C && D
________ 20. x = !(A && B) || !(D && C)
Write c++ statements for each of the following (no declarations necessary here):
In: Computer Science
Using c++, complete the functions to fulfill requirements. Basically, turn test case into unit test code.
You may only use:
- iostream, cmath
/*
BLAS Level 1 function declarations
*/
#ifndef BLAS_H
#define BLAS_H
/*
Find the element with the maximum absolute value.
Input:
x : vector (as array of doubles)
len : number of elements in x (dimension)
Output: index of the first element with maximum absolute
value
Errors: returns -1 if vector is empty (len = 0)
*/
int amax(
const double* x,
const unsigned int len);
/*
Sum the absolute values.
Input:
x : vector (as array of doubles)
len : number of elements in x (dimension)
Output: sum of the absolute values of the elements.
Returns 0 if x is empty.
*/
double asum(
const double* x,
const unsigned int len);
/*
Generalized vector addition (afine transformation)
Input:
a : scalar value
x : vector (as an array of doubles)
y : vector (as an array of doubles)
len : number of elements in x and y (dimension,
assumed equal)
Output: None. y is updated as y = a*x + y
*/
void axpy(
const double a,
const double* x,
double* y,
const unsigned int len);
/*
Copy a vector.
Input:
x : source vector (as an array of doubles)
y : destination vector (as array of doubles)
len : number of elements in x and y (dimension,
assumed equal)
Output: None. y is updated as y = x
*/
void copy(
const double* x,
double* y,
const unsigned int len);
/*
Dot (inner) product of two vectors.
Input:
x : vector (as an array of doubles)
y : vector (as an array of doubles)
len : number of elements of x and y (dimension,
assumed to be equal)
Output: dot (inner) product of x and y: x . y
Return 0 if x and y are empty.
*/
double dot(
const double* x,
const double* y,
const unsigned int len);
/*
Euclidean norm of a vector.
Input:
x : vector (as an array of doubles)
len : number of elements of x (dimension)
Output: magnitude (length) of x as the distance from the origin to
x (as a point)
Returns 0 if x is empty.
*/
double norm2(
const double* x,
const unsigned int len);
/*
Scale a vector.
Input:
a : scalar value
x : vector (as an array of doubles)
len : number of elements in x (dimension)
Output: None. x is scaled by a: x = a*x;
*/
void scale(
const double a,
double* x,
const unsigned int len);
/*
Swap two vectors.
Input:
x : vector (as an array of doubles)
y : vector (as an array of doubles)
len : number of elements in x and y (dimension,
assumed to be equal)
Output: None. x and y are updated as x,y = y,x
*/
void swap(
double* x,
double* y,
const unsigned int len);
#endif
In: Computer Science
In c++ format please
Bank Charges
A bank charges $10 per month plus the following check fees for a
commercial checking account:
$.10 each for fewer than 20 checks
$.08 each for 20–39 checks
$.06 each for 40–59 checks
$.04 each for 60 or more checks
The bank also charges an extra $15 if the balance of the account
falls below $400 (before any check fees are applied).
Write a program that asks for the beginning balance and the number of checks written. Compute and display the bank’s service fees for the month.
Input Validation: Do not accept a negative value for the number
of checks written. If a negative value is given for the beginning
balance, display an urgent message indicating the account is
overdrawn.
In: Computer Science
Please note: This is in Visual Basic.
Create an application. Add a text box, a label, and a button to the form. If the user enters a number that is greater than 100 in the text box, the button's "click" event procedure should display the result of multiplying the number by 5. Otherwise, it should display the result of dividing the number by 5. Code the procedure.
In: Computer Science
Create a Java program which prints a truth table for any 2
variables propositional function.
Assuming variables p and q. Instead of the symbols for "and" and
"or", just used the words. For "not", use the tilde "~"
Prompt the user for 3 questions
1: "p and q"? Or "p or q"?
2: Do you want to negate p?
3: Do you want to negate q?
For example, suppose in a menu system the user chose "p or q", and to negate q. The output should look similar to this:
p | q | (p or ~q)
------------------
T | T | T
T | F | T
F | T | F
F | F | T
In: Computer Science
The Board of Directors of Northwind have appointed Doug Hanus at their new CEO and Jeff Hogan as their operational manager. They are planning to devote their first two weeks in office to gain a better understanding of Northwind’s supply chain and marketing processes. As senior database analyst for Northwind, it is your responsibility to code appropriately structured SQL statements for retrieving the following information requested by Doug and Jeff. They need it on or before 09/29/2019.
In: Computer Science
2. Determine whether the following Propositional Logic statements are valid or invalid arguments. You may use a truth table, proofs using rules of inference, or resolution (specify which method you are using).
(a) p→q, ~q→r, r; ∴p
(b) ~p∨q, p→(r∧s), s→q; ∴q∨r
(c) p→(q→r), q; ∴p→r
In: Computer Science
Please, i need Unique answer, Use your own words (don't copy and paste).
*Please, don't use handwriting.
DDoS attack
Based on the Internet, access to the article intituled: ‘A survey on DDoS attack and defense strategies from traditional schemas to current techniques’.
1- Describe the DDoS attack.
2- Provide at least two exploited vulnerabilities used by hacker to perform the DDoS attack.
3- Provide at least two countermeasures against DDoS.
In: Computer Science
We are given an array of n numbers A in an arbitrary order. Design an algorithm to find the largest and second largest number in A using at most 3/2n -2 comparisons.
(i) describe the idea behind your algorithm in English (3 points);
(ii) provide pseudocode (5 points);
(iii) analyze the number of comparisons used in your algorithm (2 points).
In: Computer Science