Questions
Question #1 Please specify he output of the following code (2.4) # import the pandas library...

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...

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....

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...

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:

  • circleCircumference = 2πr
  • circleArea = πr2
  • sphereArea = 4πr2
  • sphereVolume = 43πr3

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...

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

Read Ch. 3. Using the C++ editor, type the following program: #include <iostream> #include <string> using...

  1. Read Ch. 3. Using the C++ editor, type the following program:

#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;

}

  1. Compile and run. What does the cin statement do?
  2. What does the cout statement do?
  3. Is name a variable or a constant?
  4. What type is name?
  5. Add the following line to the declaration statements:

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.

  1. Add a line to print the age to the screen. Compile and Run.
  2. Add the following line to the declaration statements:

float bodyTemp;

              Add the lines to input and out your body temperature. Compile and run.

              What type is bodyTemp? Describe this type.

  1. Add the appropriate declaration, input and output statement for each of the following:

Height (hint, use two variables)

Weight

Sex (hint, use the char type)

Last name

  1. Turn in:
    1. The final program
    2. The final output

Answers to these questions only:

  1. What is the integer data type and how is it declared in C++?
  2. Give an example of where the integer type might be used.
  3. What is the real data type and how is it declared in C++?
  4. Give an example of where the real type might be used.
  5. What is the string data type and how is a string declared in C++?
  6. Give an example of where the string type might be used.
  7. What is the boolean type and how is an boolean declared in C++?
  8. Give an example of where the boolean type might be used.

In: Computer Science

Give the value of x (x is an integer and assume integer arithmetic for all operations)....

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):

  1. Output a message that says "Hello everybody"  

                                                                                   

  1. Prompt the user to enter a name.                      
  1. Input a name into a variable.    
                             
  2. Output Hello and the name you input.  
  3. Prompt for two numbers.                                 
  1. Input two numbers.           

                                   
  2. Compute the sum of the two numbers.  
  3. Output "the sum is" followed by the sum.   
           
  4. Modify the previous statement to echo print the two numbers entered. " the sum of x and y is z"; Do not use x, y, z use variables from above.

  1. Input the price of an item.             
                        
  2. Calculate the sales tax.                         
  1. Compute the total price, given price and sales tax.
  1. Compute the average of three test scores.     
      

In: Computer Science

Using c++, complete the functions to fulfill requirements. Basically, turn test case into unit test code....

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...

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,...

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...

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...

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.

  1. A listing of Northwind’s suppliers. [1 pt.]

  1. A listing of Northwind’s suppliers based in Norway and Sweden. [2 pts]

  1. A listing of Northwind’s product categories and the description of each product category. [2 pts]

  1. A clearer picture of the geographical footprint of their customers and suppliers - they want separate listings of the countries in which their customers and suppliers are located. [2 pts]

  1. The average, sum, maximum, and minimum per unit cost across all products in their product line. They would also like to know the names of Northwind’s products having per unit cost between 30 and 50 (both inclusive). [2 pts]
  1. A count and a listing of the cities and corresponding countries in North America (USA, Canada, Mexico) where they have a customer base. [3 pts]

  1. A listing of the product names and its corresponding category for products from suppliers based in Germany and France. [4 pts]

  1. A list of countries outside of North America (i.e. USA, Canada, Mexico) where they have less than 3 suppliers. [4 pts]

  1. For OrderIDs 10258, 10259, and 10260, a listing of the corresponding customer, employee who accepted the order, and the shipper. The listed must be sorted alphabetically by customer name. [5 pts]

  1. A listing of the product names and supplier names for all products that make up OrderIDs 10254 and 10260. [5 pts]

In: Computer Science

2. Determine whether the following Propositional Logic statements are valid or invalid arguments. You may use...

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...

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...

  1. 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