Answer:
The output is
C
A
Explanation:
Given
The given code segment
Required
The output of test_1()
When test_1() is called from main, the following is executed:
def test_1():
test_3() ---- This calls test_3()
print("A") --- This is then executed after test_3() has been executed
For test_3()
def test_3():
print("C") --- This prints C
Back to test_1()
print("A") --- This prints A
So, the output is:
C
A
In this exercise we have to use the knowledge of computational language in python to write the code.
We have the code in the attached image.
The code in python can be found as:
def test_1():
test_3()
print("A")
def test_3():
print("C")
Back to test_1()
print("A")
See more about python at brainly.com/question/26104476
In java I need help on this specific code for this lab.
Problem 1:
Create a Class named Array2D with two instance methods:
public double[] rowAvg(int[][] array)
This method will receive a 2D array of integers, and will return a 1D array of doubles containing the average per row of the 2D array argument.
The method will adjust automatically to different sizes of rectangular 2D arrays.
Example: Using the following array for testing:
int [][] testArray =
{
{ 1, 2, 3, 4, 6},
{ 6, 7, 8, 9, 11},
{11, 12, 13, 14, 16}
};
must yield the following results:
Averages per row 1 : 3.20
Averages per row 2 : 8.20
Averages per row 3 : 13.20
While using this other array:
double[][] testArray =
{
{1, 2},
{4, 5},
{7, 8},
{3, 4}
};
must yield the following results:
Averages per row 1 : 1.50
Averages per row 2 : 4.50
Averages per row 3 : 7.50
Averages per row 4 : 3.50
public double[] colAvg(int[][] array)
This method will receive a 2D array of integers, and will return a 1D array of doubles containing the average per column of the 2D array argument.
The method will adjust automatically to different sizes of rectangular 2D arrays.
Example: Using the following array for testing:
int [][] testArray =
{
{ 1, 2, 3, 4, 6},
{ 6, 7, 8, 9, 11},
{11, 12, 13, 14, 16}
};
must yield the following results:
Averages per column 1: 6.00
Averages per column 2: 7.00
Averages per column 3: 8.00
Averages per column 4: 9.00
Averages per column 5: 11.00
While using this other array:
double[][] testArray =
{
{1, 2},
{4, 5},
{7, 8},
{3, 4}
};
must yield the following results:
Averages per column 1: 3.75
Averages per column 2: 4.75
My code is:
public class ArrayDemo2dd
{
public static void main(String[] args)
{
int [][] testArray1 =
{
{1, 2, 3, 4, 6},
{6, 7, 8, 9, 11},
{11, 12, 13, 14, 16}
};
int[][] testArray2 =
{
{1, 2 },
{4, 5},
{7, 8},
{3,4}
};
// The outer loop drives through the array row by row
// testArray1.length has the number of rows or the array
for (int row =0; row < testArray1.length; row++)
{
double sum =0;
// The inner loop uses the same row, then traverses all the columns of that row.
// testArray1[row].length has the number of columns of each row.
for(int col =0 ; col < testArray1[row].length; col++)
{
// An accumulator adds all the elements of each row
sum = sum + testArray1[row][col];
}
//The average per row is calculated dividing the total by the number of columns
System.out.println(sum/testArray1[row].length);
}
} // end of main()
}// end of class
However, it says there's an error... I'm not sure how to exactly do this type of code... So from my understanding do we convert it?
Answer:
Explanation:
The following code is written in Java and creates the two methods as requested each returning the desired double[] array with the averages. Both have been tested as seen in the example below and output the correct output as per the example in the question. they simply need to be added to whatever code you want.
public static double[] rowAvg(int[][] array) {
double result[] = new double[array.length];
for (int x = 0; x < array.length; x++) {
double average = 0;
for (int y = 0; y < array[x].length; y++) {
average += array[x][y];
}
average = average / array[x].length;
result[x] = average;
}
return result;
}
public static double[] colAvg(int[][] array) {
double result[] = new double[array[0].length];
for (int x = 0; x < array[x].length; x++) {
double average = 0;
for (int y = 0; y < array.length; y++) {
average += array[y][x];
}
average = average / array.length;
result[x] = average;
}
return result;
}
You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web page, extracts the URLs present in that page, and then recursively fetches new pages using the extracted URLs. The end goal of a web crawler is to collect text data, images, or other resources present in order to validate resource URLs or hyperlinks on a page. URL validators can be useful to validate if the extracted URL is a valid resource to fetch. In this scenario, you will build a URL validator that checks for supported protocols and file types.
What you need to do?
1. Writing detailed comments and docstrings
2. Organizing and structuring code for readability
3. URL = :///
Steps for Completion
Task
Create two lists of strings - one list for Protocol called valid_protocols, and one list for storing File extension called valid_ftleinfo . For this take the protocol list should be restricted to http , https and ftp. The file extension list should be hrl. and docx CSV.
Split an input named url, and then use the first element to see whether the protocol of the URL is in valid_protocols. Similarly, check whether the URL contains a valid file_info.
Task
Write the conditions to return a Boolean value of True if the URL is valid, and False if either the Protocol or the File extension is not valid.
main.py х +
1 def validate_url(url):
2 *****Validates the given url passed as string.
3
4 Arguments:
5 url --- String, A valid url should be of form :///
6
7 Protocol = [http, https, ftp]
8 Hostname = string
9 Fileinfo = [.html, .csv, .docx]
10 ***
11 # your code starts here.
12
13
14
15 return # return True if url is valid else False
16
17
18 if
19 name _main__': url input("Enter an Url: ")
20 print(validate_url(url))
21
22
23
24
25
Answer:
Python Code:
def validate_url(url):
#Creating the list of valid protocols and file name extensions
valid_protocols = ['http', 'https', 'ftp']
valid_fileinfo = ['.html', '.csv', '.docx']
#splitting the url into two parts
url_split = url.split('://')
isProtocolValid = False
isFileValid = False
#iterating over the valid protocols and file names for validity
for x in valid_protocols:
if x in url_split[0]:
isProtocolValid = True
break
for x in valid_fileinfo:
if x in url_split[1]:
isFileValid = True
break
#Returning the result if the URL has both valid protocol and file extension
return (isProtocolValid and isFileValid)
url = input("Enter an URL: ")
print(validate_url(url))
Explanation:
The image of the output code is attached. Hope it helps.
Assume a manufacturing company which manufactures and sells several electronic
products. This company has a list of suppliers who supply various components for
different products. Several components assembled together form a product. A product
will be manufactured in many work centers. Each product contains several components.
A product has at least one component and may comprise of several components. A
component must belong to a product and the same component can be used in multiple
products. Also mention the quantity of the component which a product requires.
Company has a list of suppliers who supply various components. A supplier may not
be supplying any component and may supply several components. A component must
be supplied by at least one supplier or several suppliers may provide the same
component. A supplier supplies the quantity and unit price of the products. A supplier
also supplies the quantity and unit price of the components. Each product will be
manufactured in single or multiple work centers. A work center may not produce a
product and may produce several products. Each work center will have one or more
employees and an employee would be working in single work center only. A customer
may not place any order and may place multiple orders. But an order will belong to a
specific customer only. Each order may contain single product or multiple products and
the same product may be demanded in many orders.
Construct an ER diagram for the manufacturing company.
Answer:
reboot it
Explanation:
Acróstico sobre mouse
What is output?
public class Division{
public static double division(double a, double b) throws Exception {
if(b == 0)
throw new Exception("Invalid number.");
return a / b;
}
public static void main(String[] args) {
try {
System.out.println("Result: " + division(5, 0));
}
catch (ArithmeticException e) {
System.out.println("Arithmetic Exception Error");
}
catch (Exception except) {
System.out.println("Division by Zero");
}
catch(Throwable thrwObj) {
System.out.println("Error");
}
}
}
A. Error.
B. Arithmetic Exception Error.
C. Arithmetic Exception Error Division by Zero Error.
D. Division by zero.
Answer:
D. Division by zero.
Explanation:
This Java code that is being provided in the question will output the following error.
Division by zero
This is because the main method is calling the division method and passing 0 for the variable b. The method detects this with the if statement and creates a new Exception. This exception is grabbed by the catch(Exception exception) line and prints out the error Division by zero.
How does it relate
to public domain
and fair use?
The UNIX cal command prints out the calendar of the month/year that the user enters. Type in the following, one at a time, and observe the output:
cal 3 2014 cal 2014 cal 1 1
To learn more about this command, type in man cal for help.
Write a program named cal.c that prints out the following (which is the output when you type in cal 10 2018 in UNIX). Note that you are not asked to implement the cal command. You can assume that you know October 1 is a Monday. You will need to use loops and the % operator.
October 2018 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Solution :
#include<[tex]$\text{stdio.h}$[/tex]>
int [tex]$\text{dayofweek}$[/tex](int d, [tex]$\text{int m}$[/tex], int y){
static [tex]$\text{int t}[]$[/tex] = { 0, [tex]$3,2$[/tex], 5, [tex]$0,3$[/tex], 5, 1, [tex]$4,6,2,4$[/tex] };
y -= [tex]$m<3$[/tex];
return ([tex]$y+$[/tex] y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
int main() {
int month,year,i;
printf("Enter Month : ");
scanf("%d",&month);
printf("Enter Year : ");
scanf("%d",&year);
//find week day number
int day = dayofweek(1,month,year);
char * weekDays[] = {"Su","Mo","Tu","We","Th","Fr","Sa"};
printf("\n");
//print week day header
for(i=0;i<7;i++)
printf("%s ",weekDays[i]);
printf("\n");
//print days accordingly
for(i=0;i<day;i++)
printf(" ");
for(i=day;i<=day+30;i++){
printf("%-2d ",i-day+1);
if((i+day)%7==0)
printf("\n");
}
}
What does an operating system provide so you can interact with a device
Answer:
Operating system software provides the user interface for interacting with the hardware components, whereas application software enables you to accomplish specific tasks.
Explanation:
please give me brainlist and follow
An operating system provides graphical user interface, which enables the user to interact seamlessly with a computer device.
Graphical user interface (GUI) provides user-friendly visual representations to help the user to manage the human interaction with the device via the operating system.
Some graphical user interface tools include icons, menus, and mouse.
Thus, with visual representations of data and operating instructions, users are able to understand the operating system and interact easily with the computer device.
Read more about graphical user interface at https://brainly.com/question/16956142
A processor has word-addressable memory with all instructions of length 1 word (which is equal to 4 bytes). At a given point in time, the current instruction being executed has an operand field with the value 7C30. At this time, suppose the Program Counter contains the address 49A072, the register R3 contains the value 5600, and the register R4 contains the value 3A. All addresses and values above are in hex. For each of the following addressing modes, find the effective address of the operand:______.
a) Direct mode
b) PC-relative mode
c) Displacement mode with base register R3 and displacement given by the operand field
d) Indexed mode with index register R4 and base address given by the operand field
Answer:
i dont
Explanation:
know im lazy to do it but it looks easy just put some effort into it youg ot it!
What are the purposes of a good web page design? The purpose of a good web page design is to make it and .
Answer:
responsiveness and intuitive
Explanation:
The two main purposes of a good web page design is responsiveness and intuitive. A webpage needs to be designed in such a way that the individual using it can easily find what they are looking for and understand what each function in the webpage does without having to ask for help or go through an extensive tutorial. They need to be able to use the website for the first time and immediately be able to use it as if they have used it countless times before. The webpage also needs to be designed with responsiveness in mind. So much so that the webpage runs fluently, loads images fast, and scales to the size of the monitor correctly. As a rule the webpage should not take longer than 2 seconds to load.
what is the weather in Ireland?
Answer:
Year-round, Irish weather as a whole tends to stick with what it knows: Mildly crisp weather, around 270 days of rain, with sunshine and wind. Although slight fluctuations occur dependent on the month and season, the average yearly temperature is around 50 degrees Fahrenheit.
Answer:
hi
Explanation:
The climate of Ireland is mild, humid and changeable with abundant rainfall and a lack of temperature extremes. ... January and February are the coldest months of the year, and mean daily air temperatures fall between 4 and 7 °C (39.2 and 44.6 °F) during these months.
have a nice day
I love Ireland very much
If you notice that a worksheet displays columns A, B, C, E, and F, what happened to column D?
Answer:
HUDSU
Explanation:WGSDBHEUIWDBWJJ
Need to compress this IPv6 Address
ad93:a0e4:a9ce:32fc:cba8:15fe:ed90:d768
I can't underatnd your question
SORRY
Question 20:
Which of the following scenarios involve computers making predictions based on the analysis of
patterns in large data sets?
Select two answers.
Astate education board analyzing demographic information and academic records to identify students at risk
of dropping out of school.
The federal government analyzing state spending data to identify which states spent the most on social
services
A video streaming service analyzing viewer's habits to suggest videos based on the viewing history of other
viewers.
An airline analyzing flight records to determine the routes it operates with the least bookings.
Answer:
A video streaming service analyzing viewer’s habits to suggest videos based on the viewing history of other viewers.
A state education board analyzing demographic information and academic records to identify students at risk of dropping out of school.
Explanation:
I just took the test and passed when you have multiple choice questions always pick ones that similar to each other and make sure it fit the question.
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers.
For this program, adjust the values by dividing all values by the largest value. The input begins with an integer indicating the number of floating-point values that follow.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))
Ex: If the input is:
5 30.0 50.0 10.0 100.0 65.0
the output is:
0.30 0.50 0.10 1.00 0.65
The 5 indicates that there are five floating-point values in the list, namely 30.0, 50.0, 10.0, 100.0, and 65.0. 100.0 is the largest value in the list, so each value is divided by 100.0.
For coding simplicity, follow every output value by a space, including the last one
1 #include
2 #include
3 #include
4 using namespace std;
5
6 int main() {
7
8 /* Type your code here. */
9
10 return 0;
11 }
12
Answer:
5.23 LAB: Adjust values in a list by normalizing When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers.
Explanation:
Which of the following describes a codec? Choose all that apply.
a computer program that saves a digital audio file as a specific audio file format
short for coder-decoder
converts audio files, but does not compress them
Answer:
A, B
Explanation:
Think of an aspect of HTML that you found challenging to master. Why is that aspect of HTML important? What are some future situations that you could use it in?
Answer:
html is a thing that u can to create an website business that u can make money on it
Briefly explain how Riboflavin deficiency lead to disease state.
Answer:
Severe riboflavin deficiency can impair the metabolism of other nutrients, especially other B vitamins, through diminished levels of flavin coenzymes [3]. Anemia and cataracts can develop if riboflavin deficiency is severe and prolonged [1]. The earlier changes associated with riboflavin deficiency are easily reversed.
there are several application to assist you to surf through the internet mention three regarding computer
Answer:
E-mailweb browsingpeer-to peer servicesAnimation timing is does not affect the
speed of the presentation
Select one:
True
False
Answer:
True
Explanation:
I think it's true.....
Which technologies combine to make data a critical organizational asset?
Answer: Is in the image I attached below of my explanation. Hope it helps! Have a wonderful day! <3
Explanation: Brainliest is appreciated, I need 2 more for my next last rank please!
Complete the problem about Olivia, the social worker, in this problem set. Then determine the telecommunications tool that would best meet Olivia's needs.
PDA
VoIP
facsimile
Internet
Answer:
PDA is the correct answer to the following answer.
Explanation:
PDA refers for Programmable Digital Assistant, which is a portable organizer that stores contact data, manages calendars, communicates via e-mail, and manages documents and spreadsheets, typically in conjunction with the user's personal computer. Olivia needs a PDA in order to communicate more effectively.
what name is given to the method used to copy a file onto a CD
Answer: Burn or Write
Explanation:
Burn is a colloquial term meaning to write content to a CD , DVD , or other recordable disc. DVD and CD drives with recording capabilities (sometimes called DVD or CD burner s) etch data onto the disks with a laser .
Consider the following program:
def test_1():
test_3()
print("A")
def test_2():
print("B")
test_1()
def test_3():
print("C")
What is output by the following line of code?
test_1()
C
A
B
C
A
C
C
A
Answer:
this would be answer D
Explanation:
In this exercise we have to use the knowledge of computational language in python to write the code.
We have the code in the attached image.
The code in python can be found as:
def test_1():
test_3()
print("A")
def test_3():
print("C")
Back to test_1()
print("A")
What is program?A computer can run multiple programs simultaneously, and each program can be in a different state. There are three states a program can be in: running, blocked, and ready. If a program is running, it means that it is currently using the computer's resources, such as the processor, memory, and I/O devices, to perform its tasks.
On the other hand, if a program is blocked, it means that it is waiting for a resource to become available, such as a file, network connection, or input from the user. In the scenario you mentioned, "Program A" is in the running state, meaning it is actively using the computer's resources.
Therefore, Program B" is in the blocked state, meaning it is waiting for a resource to become available so it can continue to run.
Learn more about program on:
https://brainly.com/question/30613605
#SPJ3
Which of the following describes the line spacing feature? Select all that apply. adds space between words adds space between lines of text adds space between paragraphs adds space at the top and bottom of a page adds bullet points or numerical lists
Answer:
adds space between lines of text
adds space between paragraphs
Explanation:
What is the output of the following code?
int num=25;
if (num > 5)
System.out.print(num + " ");
num += 10;
}
if (num > 30){
System.out.print(num + " ");
num += 5;
}
if (num > 45 ) {
System.out.print(num);
}
Answer:
25 35
Explanation:
First if checks if num is greater than 25, it is so it prints 25 with a space after and adds 10 to num (num is now 35)
Then it checks if num is greater than 30, it is, so it prints 35 with a space after and adds 5 to num (num is now 40)
Lastly, it checks if num is greater than 45, it is not, so the program terminates with output: "25 35 " (note the space at the end)
the
Wnte
that
Program
will accept three
Values of
sides of a triangle
from
User and determine whether Values
carceles, equal atera or sealen
- Outrast of your
a
are for
an
Answer:
try asking the question by sending a picture rather than typing
What is the creative strategy for music application.
Answer:
The City of Vancouver has allocated $300,000 to support the growth and development of the Vancouver Music Strategy, developed to address current gaps in the music ecosystem that support: Creating a sustainable, resilient, and vibrant music industry.
Explanation:
Make these negative sentences more positive and polite. Keep the meaning.
1.Don’t run for the bus. You might slip on the ice and fall
2.Don’t tell me what you can’t do.
3.Don’t eat with your mouth open.
4.Don’t submit an incomplete report.
Answer:
You should not run for the bus. You could slip on the ice and fall
Would you stop telling me what you can't do
Could you not eat with your mouth open
You should not submit an incomplete report
Answer:
You should not run for the bus. You could slip on the ice and fall
please stop telling me what you can't do.
please do not eat with your mouth open
you shouldn't submit an incomplete report. it could affect your grades negatively.
Explanation:
hope this helps!
~mina
Which range of values would result in 10 elements stored in an array?
1-11
0-9
0-10
2-12
Answer:
0-9
Explanation:
count 0 as 1
len(0,1,2,3,4,5,6,7,8,9)=10