Questions
Write an example of a Python while loop that is infinite, calls the functions first(), second()...

Write an example of a Python while loop that is infinite, calls the functions first(), second() and third() in that order in the body of the loop, but skips calling second() and third() if first() returns a value of False, and exits if second() returns a value of False.


Declare a Python function named sumEm() that accepts three numeric parameters and returns the sum of the three numbers.


Assume sumEm() is declared in a module named myMod.py, which your program has imported. Show by code example how to call sumEm().

Declare a Python function named str2val() that accept a numeric parameter and returns a list containing the numeric value passed, two times the numeric value passed and the string representing the value passed.


What does it mean in Python to say that a function is “polymorphic”?


What is a function stub in Python, and why are they useful? Show by code example a stub that uses the pass keyword.

In: Computer Science

JAVA Implement a public class method named comparison on a public class Compare that accepts two...

JAVA

Implement a public class method named comparison on a public class Compare that accepts two Object arguments.

It should return 0 if both references are equal.

1 if both objects are equal.

and -1 otherwise.

(SUPER IMPORTANT) Either reference can be null, so you'll need to handle those cases carefully!

Here is what I have so far:

public class Compare {

public static int comparison(Object a, Object b) {

  if (a == null || b == null) {

   return null;

  } else if (a.equals(b)) {

   return 0;

  } else if (a == b) {

   return 1;

  } else {

   return -1;

  }

   

}

  

}

I think I'm off with the null part. Thanks!

In: Computer Science

Network Reconfiguration Reconfigure the network in the file provided. Then submit a PNG or PDF file...

Network Reconfiguration
Reconfigure the network in the file provided. Then submit a PNG or PDF file of your updated network diagram and show screenshot evidence that the project requirements for the following critical elements:
A. Properly configure the VLAN for guest and video connections to meet the project requirements. Submit a screenshot of the VLAN table. [CYB-210-01]
B. Properly configure the guest wireless network to meet the project requirements. Submit a screenshot of the wireless settings for the wireless router. [CYB-210-03]
C. Make sure that devices are connected to the guest wireless network to meet the project requirements. IP addresses for the devices should be noted in the network diagram PNG or PDF.
D. Make sure that cameras are connected to the video network to meet the project requirements. IP addresses for the cameras should be noted in the network diagram PNG or PDF.
E. Make sure that guest and video networks are properly segmented. Submit screenshots of ping tests that prove you have met this project requirement. [CYB-210-01]

II. Explanation of Network Segregation
Articulate a response to the questions below.
A. Describe how I segmented the network traffic to meet the project requirements for guest and video connections. [CYB-210-01]
B. Explain how I considered the scalability of the guest wireless network in order to meet the project requirements (IP addressing, leasing, etc.). [CYB-210-01]

In: Computer Science

C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is...

C# CODE C#

1) Write a program that calculates a student's GPA. Remember, an A is worth 4 points, a B is worth 3 points, a C is worth 2 points, a D is worth 1 point, and an F is worth 0 points. For the purposes of this assignment, assume that all classes carry the same number of credit hours.

2) Use a sentinel-controlled loop to gather a variable number of letter grades. This should terminate the loop if the user enters an "X." This means that users should input as many grades as they like. When they are finished, they need to input an X, and at that point, the program will return the results.

C# CODE C# THANK YOU!

In: Computer Science

what Al is and isn't it by Sebastian Thrun

what Al is and isn't it by Sebastian Thrun

In: Computer Science

please use text only! Instructions Consider the provided C++ code in the main.cpp file: The function...

please use text only!

Instructions

Consider the provided C++ code in the main.cpp file:

The function func2 has three parameters of type int, int, and double, say a, b, and c, respectively. Write the definition of func2 so that its action is as follows:

  • Prompt the user to input two integers and store the numbers in a and b, respectively.
  • If both of the numbers are nonzero:
  • If a >= b, the value assigned to c is a to the power b, that is, aᵇ.
  • If a < b, the value assigned to c is b to the power a, that is, bᵃ.
  • If a is nonzero and b is zero, the value assigned to c is the square root of the absolute value of a.
  • If b is nonzero and a is zero, the value assigned to c is the square root of the absolute value of b.
  • Otherwise, the value assigned to c is 0. The values of a, b, and c are passed back to the calling environment. After completing the definition of the func2 and writing its function prototype, run your program.

Provided code

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
void func1();
void func2(/*formal parameters*/);
int main()
{
int num1, num2;
double num3;
int choice;
cout << fixed << showpoint << setprecision(2);
do
{
func1();
cin >> choice;
cout << endl;
if (choice == 1)
{
func2(num1, num2, num3);
cout << num1 << ", " << num2 << ", " << num3 << endl;
}
}
while (choice != 99);
return 0;
}
void func1()
{
cout << "To run the program, enter 1." << endl;
cout << "To exit the pogram, enter 99." << endl;
cout << "Enter 1 or 99: ";
}
void func2(/*formal parameters*/)
{
//Write the body of func2.
}

TEST CASES

Input

1
2
9
99

Output

81

TEST CASE 2

Input

1
5
8
99

Output

32768

In: Computer Science

A new idea has come to light in which an attempt is promoted to make a...

A new idea has come to light in which an attempt is promoted to make a program run a little faster. Since memory is way away from the CPU it behooves use to keep the active variables closer to the CPU (in a buffer) and try to cut down on the number of trips all the way to memory to get data the CPU is needing. This project has been assigned to you. Should you accept and should you succeed you will then receive appropriate compensation (a grade).

The problem is to keep active variables closer to the CPU where the variables will be kept in a buffer. When the CPU needs the data from a variable, the first place to look is in the buffer. If found that variable’s value is returned and that variable becomes the most recently used variable. If the variable is not found, then the variable’s value is fetched form memory then is added to the buffer, again becoming the most recently used variable. Now the buffer is only so big and will hold only so many variables at a time, so when the buffer is full and you add a new variable to the buffer, then an old variable needs to fall off (out of) the buffer. The variable that falls out represents a less recently used variable it leaves the buffer.

Your effort (your program) is to manage the buffer. You are to write a program that will input a stream of accessed variables simulating the variables accessed in a running program. The buffer will be implemented as a link list. Any variable accessed must first be determined if the variable is in the buffer. If so, move the variable to front of list to represent most recently used. The variables at the end of the list are the less recently used. Any variable not found in the list will be placed/added at the front of the list. At all times the buffer cannot exceed its limits.

You are to simulate different buffer sizes to see if the larger buffer size really saves much on the true memory access. So have your program test with buffer sizes of 4, 5, 6, 7, and 8, the max number of variables in the buffer. Run your program, reading through the data 5 times, one for each buffer size to test. Keep up with the number of times you have to access true memory (ie the number of times a variable is added to the buffer). Be sure not to exceed the buffer size with the number of variables in the list. Print out the buffer size and the number of memory accesses required to simulate this intermediate storage. On end-of-file for each buffer size tested, print out the current variables in the buffer at the time all variables have been read/input from the file.

The Data Structure we are implementing is called a ‘self-organizing list’ in which we have a list and on each access to a node in the list, the list is reorganized as new variables are encountered.

INPUT: Your input file for the variable stream is “LinkL Var Stream.txt”. Below is the input from the file "LinkL Var Stream.txt."

tom sue joe finney tobee total joe joe tom total goo tobee tobee total sid mikey tom tobee blue blue blue sue goo blue blue miney tobee sumup moreso sid sid mikey mikey lesso maybso goo sidtom tom tom sue blue goo sumup tobee finney finney tobee joe joe tom total goo tobee tobee total sid mikey tom tobee blue blue blue sue mikey joe where blue tom finney blue goo joe mikey where finney joe mikey goo blue blue miney tobee cooly sumup moreso sid sid mikey mikey lesso maybso goo sid tom mikey lisso maybso goo goo total where about about tom blue sid finney jojo tobee joe joe tom total goo tobee tobee total sid mikey tom tobee blue blue blue sue goo blue blue miney tobee sumup lisso moreso sid mikey mikey cooly lisso goo tobee tobee total sid mikey tom tobee blue blue blue sue so so so total tom lesso maybso goo ghost sid tom blue sid where joe sue joe sue tom sue where sid tom mikey lisso jo sumup jo jo maybso goo goo sumup total sumup lisso where about cooly about tom blue sid finney tobee ghost ghost cooly joe joe tom total goo blue blue miney moreso sid sid mikey mikey tom tobee blue blue blue sue so so so total tom lesso goo tobee tom blue sid sid goo maybso goo sid tom blue sid where joe ghost sue joe sue tom sue mikey total conditions select windows joe where blue tom finney goo sid blue blur blue joe sumup total miney total categories advanced estate finney goo sid blue blur box west team estate team estate box estate sales look windows photos english estate box estate box left conditions select windows photos sid blue blur blue joe sumup team estate box windows photos team estate photos conditions select windows photos windows photos team estate photos windows photos west left conditions west photos team estate west categories advanced estate box categories advanced west estate box select photos team select windows photos left conditions team estate left conditions west west west west select west windows select windows photos team west left conditions photos team estate box windows select left conditions windows left conditions photos team windows photos team estate box windows

OUTPUT: Each Buffer size, number of memory accesses and the last list of variables remaining in the buffer.

Program needs to be written in C++.

In: Computer Science

// function definitions go into hw08.cpp: // hw08.cpp namespace hw08 { int main(); const int ARRAY_SIZE...


// function definitions go into hw08.cpp:

// hw08.cpp

namespace hw08
{
int main();

const int ARRAY_SIZE = 5;

const int DYNAMIC_SIZE = 15;

const int TIC_TAC_TOE_SIZE = 3;


// function definitions:

//------------------------------------------------------------------------------

int increment_value(int x)
// pass a value, compute a new value by adding 5 to x and return it
{

// ...
x += 5;

// temp, replace when defining function
return x;           // included so that incomplete lab code will compile
}


void increment_pointer(int* p)
// pass a pointer, increment value of p by 1
{


p += 4;

}

void increment_reference(int& r)
// pass a reference, increment value of r by 1
{

r += 1;

}

//------------------------------------------------------------------------------

void print_2darray_subscript(double* (twoDD[])[ARRAY_SIZE], int row,
int col)
// print array using subscripts
{

for (int i = 0; i < row; i++)

{

for (int j = 0; j < col; j++)

{


cout << twoDD[i][j] << " " << endl;

}

}

}
void print_2darray_pointer(double* twoDD, int row, int col)
/* print array using pointer arithmetic */
{

for (int i = 0; i < row; i++)

{

for (int j = 0; j < col; j++)

{

// our 2d array is layed out linearly in memory as contiguous rows, one after another, there are #row rows
// each row has #col columns

// to compute the offset using pointer math
// offset from twoDD: #row (i) * #col + #col (j), result: pointer to array element
// ...

cout << *((twoDD + i * col) + j) << " ";

}

}

}

int main()
{

// console header
cout << endl;

  
// complete the following pointer examples
// indicate if the requested operation is not allowed, why not?
// Q#1 - pointer examples
int x = 10;

// ... // [1.1] variable p of type pointer to int points to x (i.e. int* p = ?;), use & to get the address of x
int* p = &x;

// ... // [1.2] variable q of type pointer to double is points to x
//error :cannot assign an int pointer to a type double // [1.2] variable q of type pointer to double is points to x
// ... // [1.3] update the value of p to 5, use * to assign to x through p
*p = 5;


// ... // [1.4] store the value of p in variable x2 of type int, use * to read x through p
int x2 = *p;


// ... // [1.5] variable p2 of type pointer to int points to x2, use & to get a pointer to x2
int* p2 = &x2;

// ... // [1.6] assign p to p2, p2 and p both point to x
p = p2;

p = &x2;

// ... // [1.7] point p to x2, what does p2 point to now?
//*p = &x2;

// complete the following reference examples
// indicate if the requested operation is not allowed, why not?
// Q#1 - reference examples
int y = 50;

// ... // [1.8] variable r of type reference to int refers to y (i.e. int& r = ?;), nothing special to do here in the initializer
int& r = y;

// ... // [1.9] variable s of type reference to double refers to y

/* double &s= &y; */

// error : cannot assign an int reference to type double

// ... // [1.10] update the value of r to 10, assign to y through r (notice * is not needed)
r = 10;


// ... // [1.11] store the value of r in variable y2 of type int, read y through r (notice * is not needed)
int y2 = r;

// ... // [1.12] variable r2 of type reference to int refers to y2, get a reference to int y2
int& r2 = y2;

// ... // [1.13] assign r to r2, the value of y is assigned to y2
r2 = r;

y = y2;

// ... // [1.14] assign y2 to r, r2 and r both point to y2

/* r = &y2; */
// error(not allowed) - cannot change the value of a reference

// ... // [1.15] variable r3 of type reference to int is defined but not initialized (i.e. does not refer to an int)

/*int& r3 */
// error(not allowed) -
//Answer : a reference must be initialized when declared

// Q#1 - pointer vs reference: increment functions
// implementation the function definitions for the following increment operations
// allows definition of variables within block scope avoiding redefinition errors
int& r3(int x, int x2, int r);

{

int x = 100;

int x2 = 25;

int* p = &x2;

int& r = x;


cout << "increment pointer vs reference" << endl << endl;


cout << x << endl;

cout << hw08::increment_value(x) << endl;   // x not changed when passed by value
cout << x << endl;


cout << x2 << endl;

hw08::increment_pointer(p);   // p points to x2, x2 updated
cout << x2 << endl;


cout << x << endl;

hw08::increment_reference(r);   // r refers to x, x updated
cout << x << endl;

}

// print 2ddoubles via pointer arithmetic
print_2darray_pointer((double*)twoDDoubles, ARRAY_SIZE, ARRAY_SIZE);

//print 2ddoubles via pointer arithmetic
print_2darray_pointer((double*)twoDDoubles, hw08::ARRAY_SIZE,
hw08::ARRAY_SIZE);

// complete the following dynamic allocation examples
/* q#4 - new, delete operator examples */
{

int* pi = new int;   // [4.1] allocate one int
int* qi = new int[5];   // [4.2] allocate five ints (an array of 5 ints)
int& ri = *pi;

int& ri2 = *qi;

int*& ri3 = qi;

ri = 100;

ri2 = 200;


double* pd = new double;   // [4.3] allocate one double
double* qd = new double[hw08::DYNAMIC_SIZE];   // [4.4] allocate DYNAMIC_SIZE doubles (an array of DYNAMIC_SIZE doubles)

//pi = pd; // [4.5] pi points to pd
// ... error explain : cannot assign a double pointer to a type int
//pd = pi; // [4.6] pd points to pi
// ... error explain : cannot assign an int pointer to a type double

double x = *pd;       // read the (first) object pointed to by pd
double y = qd[5];       // read the sixth object pointed to by qd
double z = *(qd + 10);   // read the tenth object pointed to by qd

delete pd;

delete[]qd;


cout << endl << "ri, ri2, ri3 before delete" << endl << endl;


cout << ri << endl;   // ri refers to *pi
cout << ri2 << endl;   // ri2 refers to *qi
cout << ri3 << endl;   // ri3 refers to qi

delete pi;       // [4.7] how are the values of ri, ri2, ri3 affected by delete statement?
delete[]ri3;       // [4.8] how are the values of ri, ri2, ri3 affected by delete statement?

cout << endl << "ri, ri2, ri3 after delete" << endl << endl;


cout << ri << endl;

cout << ri2 << endl;

cout << ri3 << endl << endl;

}

double* array_of_doubles = hw08::dynamic_allocation_array_doubles(1000);

// use array_of_doubles here
// ... // [4.9] free array, no longer needed
delete[] array_of_doubles;


// Q#5 - dynamic 2d arrays, indexing via subscript operator, pointer arithmetic

// tic tac toe board is an array of int pointers
// each int pointer in the board points to a row


// declare a pointer to an array of int pointers (i.e. a pointer to a pointer of type int)
int** p_p_tictactoe = new int* [TIC_TAC_TOE_SIZE];


// ... // [5.1] row1: dynamically allocate int[TIC_TAC_TOE_SIZE], use initializer list to init to {1,0,0}

p_p_tictactoe[0] = new int[TIC_TAC_TOE_SIZE]
{1, 0, 0 };


// ... // [5.2] row2: dynamically allocate int[TIC_TAC_TOE_SIZE], use initializer list to init to {0,1,0}

p_p_tictactoe[1] = new int[TIC_TAC_TOE_SIZE]
{0, 1, 0 };

// ... // [5.3] row3: dynamically allocate int[TIC_TAC_TOE_SIZE], use initializer list to init to {0,0,1}
p_p_tictactoe[2] = new int[TIC_TAC_TOE_SIZE]
{0, 0, 1 };


// print 2dints via subscript operator
print_2darray_dynamic_subscript(p_p_tictactoe,TIC_TAC_TOE_SIZE,TIC_TAC_TOE_SIZE);

/* print 2dints via pointer arithmetic */

print_2darray_dynamic_pointer(p_p_tictactoe, TIC_TAC_TOE_SIZE,TIC_TAC_TOE_SIZE);


// clean up board, go in reverse order of declaration

// [5.4] delete individual rows (i.e. rows are int arrays, use delete []);;
for (int i = 0; i < DYNAMIC_SIZE; i++)


{


delete[]p_p_tictactoe[i];


}
// [5.5] delete board (board is an array of int pointers, use delete [])
// ...
delete[]p_p_tictactoe;


return 0;

}

};
I have problem in question 5

In: Computer Science

Code in Python 1. A function named get_score has been defined which consumes no parameters and...

Code in Python

1. A function named get_score has been defined which consumes no parameters and returns an int value. Call get_score and print the result.

2.A function named area_rectangle has been defined which consumes two parameters that are both float values and returns a float value. Call area_rectangle with arguments of variables named length and width and print the result.

3. Assume a function called calculate_cone_volume is already defined. The function has 2 parameters: height and radius (in that order). calculate_cone_volume calculates the volume of a cone. V=pi*r^2*h/3

In: Computer Science

Consider the following set of processes, with the length of the CPU burst given in milliseconds...

  1. Consider the following set of processes, with the length of the CPU burst given in milliseconds

      Process            Burst Time      Priority

      P1                    2                      2

      P2                    1                      1

      P3                    8                      4

      P4                    4                      2

      P5                    5                      3

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0,

a. Draw four Gantt charts that illustrate the execution of these processes using the   following scheduling algorithms: FCFS, SJF, nonpreemptive priority (a larger priority number implies a higher priority), and RR (Quantum =2).

b. What is the turnaround time of each process for each of these scheduling algorithms? Give a table to list all results.

c. what is the waiting time of each process for each of the scheduling algorithms? Give a table to list all results.

d. which of the algorithms results in the minimum average waiting time (over all processes)

In: Computer Science

Write an assembly language program to input a string from the user. Your program should do...

Write an assembly language program to input a string from the user. Your program should do these two things:

***** I AM POSTING THIS QUESTION FOR THE THIRD TIME NOW,I WANT IT DONE USING INCLUDE IRVINE32.INC*****

1. count and display the number of words in the user input string.

2. Flip the case of each character from upper to lower or lower to upper.

For example if the user types in:   "Hello thEre. How aRe yOu?"

Your output should be:

The number of words in the input string is: 5

The output string is : hELLO THeRE. hOW ArE YoU?

In: Computer Science

In C, 1) Create variables for: your first and last name total round trip to school...

In C,

1) Create variables for:

your first and last name

total round trip to school and home (assuming you don't live on campus - make it your hometown).

cost of gas

2) Create a program that will:

output your first name and your total miles driven for the week.

output your last name with the total costs per week

In: Computer Science

The problem of placing k queens in an n×n chessboard. In this problem, you will be...

The problem of placing k queens in an n×n chessboard. In this problem, you will be considering the problem of placing k knights in a n × n chessboard such that no two knights can attack each other. k is given and k ≤ n2.

a) Formulate this problem as a Constraint Satisfaction Problem. What are the variables?

b) What is the set of possible values for each variable?

c) How are the set of variables constrained?

In: Computer Science

What is the difference between stack-dynamic and explicit heap-dynamic?  

What is the difference between stack-dynamic and explicit heap-dynamic?  

In: Computer Science

For this assignment you will write a Java program using a loop that will play a...

For this assignment you will write a Java program using a loop that will play a simple Guess The Number game. Create a new project named GuessANumber and create a new Java class in that project named GuessANumber.java for this assignment.

The program will randomly generate an integer between 1 and 200 (including both 1 and 200 as possible choices) and will enter a loop where it will prompt the user for a guess. If the user has guessed the correct number, the program will end with a message indicating how many guesses it took to get the right answer and a message that is determined by how many guesses it takes them to get the right answer. If the user guesses incorrectly, the program should respond with a message that the user has guessed either "too high" or "too low" and let them guess again.

Use the following table to determine the final message after the score is computed (note that your code MUST respond with these messages to be considered correct):

Number of Guesses     Message
-----------------     ---------------------------------------------
1                     That was impossible!
2-3                   You're pretty lucky!
4-7                   Not bad, not bad...
8                     That was not very impressive.
9-10                  Are you having any fun at all?
11 or more            Maybe you should play something else.

Sample Output This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

Enter a random seed: 99
Enter a guess between 1 and 200: 100
Your guess was too low - try again.

Enter a guess between 1 and 200: 150
Your guess was too low - try again.

Enter a guess between 1 and 200: 175
Your guess was too low - try again.

Enter a guess between 1 and 200: 187
Your guess was too low - try again.

Enter a guess between 1 and 200: 193
Your guess was too high - try again.

Enter a guess between 1 and 200: 190
Your guess was too high - try again.

Enter a guess between 1 and 200: 188
Congratulations!  Your guess was correct!

I had chosen 188 as the target number.
You guessed it in 7 tries.
Not bad, not bad...

Your code will behave differently based on the random value it selects and the choice taken by the user. Here is a second possible execution of this code:

Enter a random seed: 1024
Enter a guess between 1 and 200: 120
Your guess was too low - try again.

Enter a guess between 1 and 200: 130
Your guess was too high - try again.

Enter a guess between 1 and 200: 124
Congratulations!  Your guess was correct!

I had chosen 124 as the target number.
You guessed it in 3 tries.
You're pretty lucky!

If the user enters an invalid choice, your code should inform them that their choice was invalid and ask them to guess again.

Enter a random seed: 99
Enter a guess between 1 and 200: 259
Your guess is out of range.  Pick a number between 1 and 200.
Your guess was too high - try again.

Enter a guess between 1 and 200: -1
Your guess is out of range.  Pick a number between 1 and 200.
Your guess was too low - try again.

Enter a guess between 1 and 200: 188
Congratulations!  Your guess was correct!

I had chosen 188 as the target number.
You guessed it in 3 tries.
You're pretty lucky!

(Note that since the user picked the same random number seed as the first example, the program has selected the same value as the target number.)

Random numbers: Just like in the FunWithBranching programming assignment, you must use the Random class to generate numbers between 1 and 200. Make sure you are using int values and not doubles for this assignment!

Could you help me with how to set up the out of range part. Thanks

In: Computer Science