Answer: Option D -- Sorting an already sorted array of size n with quicksort takes O(n log n) time.
Explanation:
Sorting an already sorted array of size n with quicksort takes O(n log n) time is true about sorting functions while other options are wrong.
a_____________ may have its value change during program execution. options. flowchart,counter, Algorithm,None of them
Answer:
i think is "none of them"
Declare a struct named PatientData that contains two integer data members named heightInches and weightPounds. Sample output for the given program:Patient data: 63 in, 115 lbs#include using namespace std;/* Your solution goes here */int main() {PatientData lunaLovegood;lunaLovegood.heightInches = 63;lunaLovegood.weightPounds = 115;cout << "Patient data: "<< lunaLovegood.heightInches << " in, "<< lunaLovegood.weightPounds << " lbs" << endl;return 0;}
Answer:
struct PatientData{
int heightInches, weightPounds;
};
Explanation:
In order to declare the required struct in the question, you need to type the keyword struct, then the name of the struct - PatientData, opening curly brace, data members - int heightInches, weightPounds;, closing curly brace and a semicolon at the end.
Note that since the object - lunaLovegood, is declared in the main function, we do not need to declare it in the struct. However, if it was not declared in the main, then we would need to write lunaLovegood between the closing curly brace and the semicolon.
a) Code a statement that creates an instance of an Account class using the default constructor and stores the object that’s created in a variable named account.
b) Code a statement that creates an instance of the Account class using a constructor that has two parameters named firstName and age, and store the object in a variable named account. Assume that variables with those names have already been declared and initialized so you can pass those variables to the constructor.
c) Code a statement that sets the value of the Age property of an Account object named account to the value in a variable named newAge.
d) Code a statement that will get the value of a public static field named Count that’s defined in the Account class, and store the value in a new int variable named count. Assume that you’ve already created an object from this class that’s named account.
Answer:
a)
Account account = new Account();
b)
Account account = new Account(firstName, age);
c)
account.Age = newAge;
d)
int count = Account.Count;
Explanation:
a)
new is the keyword which is used to create an object.
Account is the class name.
account is the name of an object of class Account.
account object is created to access the class Account.
Account() is the constructor of Account class. This is the default constructor and it has no parameters. Constructor has the same name as class. When a account object is created, constructor Account will be invoked.
b)
Account is the class name.
account is the name of an object of class Account.
Account() is the constructor of Account class. This is the parameterized constructor and it has two parameters i.e. firstName and age. Constructor has the same name as class. When a account object is created, constructor Account will be invoked.
c)
account.Age = newAge;
Here account is the object name. The Age property to access and update the private field of the Account class is set to the variable named newAge.
d)
This int count = Account.Count; statement gets the value of a public static field named Count that’s defined in the Account class, and stores the value in a new int variable named count.
EAPOL operates at the network layers and makes use of an IEEE 802 LAN, such as Ethernet or Wi-Fi, at the link level.
A. True
B. False
Write a script named dif.py. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same. If they are, the script should simply output "Yes". If they are not, the script should output "No", followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file, including whitespace and punctuation. The loop should break as soon as a pair of different lines is found.
Answer:
Following are the code to this question:
f1=input('Input first file name: ')#defining f1 variable that input file 1
f2=input('Input second file name: ')#defining f2 variable that input file 2
file1=open(f1,'r')#defining file1 variable that opens first files by using open method
file2=open(f2,'r')#defining file1 variable that opens second files by using open method
d1=file1.readlines()#defining d1 variable that use readlines method to read first file data
d2=file2.readlines()#defining d2 variable that use readlines method to read second file data
if d1==d2:#defining if block that check file data
print('Yes')#when value is matched it will print message yes
exit# use exit keyword for exit from if block
for j in range(0,min(len(d1),len(d2))):#defining for loop that stores the length of the file
if (d1[j]!=d2[j]):#defining if block that check value is not matched
print('No')#print the message "NO"
print("mismatch values: ",d1[j]," ",d2[j])#print file values
Output:
please find the attached file.
Explanation:
code description:
In the above code, the "f1 and f2" variable is used for input value from the user end, in which it stores the file names. In the next step, the "file1 and file2" variable is declared that uses the open method to open the file. In the next line, the"d1 and d2" variable is declared for reads file by using the "readlines" method. Then, if block is used that uses the "d1 and d2" variable to match the file value if it matches it will print "yes", otherwise a for loop is declared, that prints files mismatch values.Answer:
first = input("enter first file name: ")
second = input("enter second file name: ")
file_one = open(first, 'r')
file_two = open(second, 'r')
if file_one.read() == file_two.read():
print("Both files are the same")
else:
print("Different files")
file_one.close()
file_two.close()
If a schema is not given, you may assume a table structure that makes sense in the context of the question. (using sql queries)
Find all Employee records containing the word "Joe", regardless of whether it was stored as JOE, Joe, or joe.
Answer:
The correct query is;
select * from EMPLOYEE where Employee_Name = 'JOE' or Employee_Name = 'Joe' or Employee_Name = 'joe';
where EMPLOYEE refer to the table name and type attribute name is Employee_Name
Explanation:
Here, the first thing we will do is to assume the name of the table.
Let’s assume the table name is EMPLOYEE, where the column i.e attribute from which we will be extracting our information is Employee_Name
The correct query to get the piece of information we are looking for will be;
select * from EMPLOYEE where Employee_Name = 'JOE' or Employee_Name = 'Joe' or Employee_Name = 'joe';
System stored procedures a. perform standard tasks on the current database b. are stored in the Master database c. can change with each version of SQL Server d. all of the above
Answer:
D. all of the above
Explanation:
A Stored Procedure (sp) is an already compiled group of SQL requests that contains either one or more statements which are stored in the master database.
A Stored Procedure can be created by using the CREATE PROC statement.
They perform standard tasks, stored in the master database and can change with each new version of SQL, so option D is correct.
The Adjacent Coins Problem Published on 2017-08-30 Consider N coins aligned in a row. Each coin is showing either heads or tails. The adjacency of these coins is the number of adjacent pairs of coins with the same side facing up. Write a program that given a non-empty zero-indexed array A consisting of N integers representing the coins, returns the maximum possible adjacency that can be obtained by reversing exactly one coin (that is, one of the coins must be reversed). Consecutive elements of array A represent consecutive coins in the row. Array A contains only 0s and/or 1s:
Answer:
Here is the JAVA code:
public class Main{
public static int solution(int[] A) { //method that takes non-empty array A consisting of 0s and 1s
int N = A.length; // number of 0s and 1s in array A
int r = 0; //result of adjacency
for (int i = 0; i < N - 1; i++; ) { // iterates through A
if (A[i] == A[i + 1]) //if i-th element of A is equal to (i+1)th element
r = r + 1; } //add 1 to the count of r
if (r == N-1) //for test cases like {1,1}
{return r-1; }
int max = 0; //to store maximum possible adjacency
for (int i = 0; i <N; i++) { //iterates through array
int c = 0;
if (i > 0) { //starts from 1 and covering the last
if (A[i-1] != A[i]) //checks if i-1 element of A is not equal to ith element of A
c = c + 1; //adds 1 to counter variable
else
c = c - 1; } //decrements c by 1
if (i < N - 1) {//starting with 0
if (A[i] != A[i + 1]) //checks if ith element of A is not equal to i+1th element of A
c = c + 1; //adds 1 to counter variable
else
c = c - 1; } //decrements c by 1
max = Math.max(max,c); } //finds the maximum of max and c
return r + max; } //returns result + maximum result
public static void main(String[] args) {
int[] A = {1, 1, 0, 1, 0, 0}; //sample array to test the method
System.out.println(solution(A));} } //calls the method passing array to it
Explanation:
The program works as follows:
A[] = {1, 1, 0, 1, 0, 0}
N = A.length
N = 6
The A has the following elements:
A[0] = 1
A[1] = 1
A[2] = 0
A[3] = 1
A[4] = 0
A[5] = 0
Program iterates through array A using for loop. Loop variable i is initialized to 0
if condition if (A[i] == A[i + 1]) checks
if (A[0] == A[0 + 1])
A[0] = 1
A[0 + 1] = A[1] = 1
They both are 1 so they are equal
r = r + 1;
Since the above if condition is true so 1 is added to the value of r Hence
r = 1
At each iteration of the loop the if condition checks whether the adjacent elements of A are equal. If true then r is incremented to 1 otherwise not.
So after all the iterations value of r = 2
if (r == N-1) evaluates to false because r=2 and N-1 = 5
So program moves to the statement:
for (int i = 0; i <N; i++)
This loop iterates through the array A
if (i > 0) condition checks if value of i is greater than 0. This evaluates to false and program control moves to statement:
if (i < N - 1) which makes if(0<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[0] != A[0 + 1]) -> if (A[0] != A[1])
We know that
A[0] = 1
A[1] = 1
So this evaluates to false and else part is executed:
value of c is decremented to 1. So c=-1
max = Math.max(max,c) statement returns the max of max and c
max = 0
c = -1
So max = 0
value of i is incremented to 1 so i = 1
At next step:
if (i < N - 1) which makes if(1<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[1] != A[1 + 1]) -> if (A[1] != A[2])
A[1] = 1
A[2] = 0
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = -1 + 1
Hence
Hence c= 0, max = 0 and i = 2
next step:
if (i < N - 1) which makes if(2<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[2] != A[2 + 1]) -> if (A[2] != A[3])
A[2] = 0
A[3] = 1
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = 0 + 1
c = 1
Hence
The statement max = Math.max(max,c) returns the max of max and c
max = 0
c = 1
So max = 1
Hence c= 1, max = 1 and i = 3
next step:
if (i < N - 1) which makes if(3<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[3] != A[3 + 1]) -> if (A[3] != A[4])
A[3] = 1
A[4] = 0
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = 1 + 1
c = 2
Hence
The statement max = Math.max(max,c) returns the max of max and c
max = 1
c = 2
So max = 2
Hence c= 2, max = 2 i = 4
next step:
if (i < N - 1) which makes if(4<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[4] != A[4+ 1]) -> if (A[4] != A[5])
A[4] = 0
A[5] = 0
So this evaluates to false and else part is executed:
value of c is decremented to 1. So c=1
max = Math.max(max,c) statement returns the max of max and c
max = 2
c = 1
So max = 2
value of i is incremented to 1 so i = 5
next step:
if (i < N - 1) which makes if(5<5) This evaluates to false
if (i > 0) evaluates to true so following statement executes:
if (A[i-1] != A[i])
if (A[5-1] != A[5])
if (A[4] != A[5])
A[4] = 0
A[5] = 0
This statement evaluates to false so else part executes and value of c is decremented to 1
Hence
max = 2
c = 0
So max = 2
value of i is incremented to 1 so i = 6
The loop breaks because i <N evaluates to false.
Program control moves to the statement:
return r + max;
r = 2
max = 2
r + max = 2+2 = 4
So the output of the above program is:
4
What is resource management in Wireless Communication? Explain its advantages
Answer:
Wireless resources management is communication to address they faster response time.
Explanation:
Wireless communication that provide bandwidth, and transmission reliable, towards development.
This communication is discovered to the date and have consumed physical layer of available wireless resources.
Wireless communication management all this critical topic and the management techniques, and limited device battery power.
Communication as the address channel loss, and multi path .
Communication are the latest resources allocation and new or next generation and technologies.
Wireless communication theoretical concepts in a manner, and the necessary mathematical tools and fundamental tools.
Wireless communication device industries up to date of the topic,readers are benefit from a basic.
What do Quadratic Selection sort, and Shell sort have in common?
They both used a/an_______based implementation in the standard form and are both relatively_____to the order of the data. The main similarity is that each one creates an environment in which a_____strategy works more efficiently.
1. blank
2. linked list
3. array
4. hybrid
5. tree
6. sensitive
7. insensitive
8. complex
9. modern
10. simple
11. retrograde
12. advanced
Answer:
a) An ARRAY ( 3 )
B) relatively INSENSITIVE ( 7 )
c) a HYBRID ( 4 )
Explanation:
They both used an array based implementation in the standard form and are both relatively insensitive to the order of the data. The main similarity is that each one creates an environment in which a hybrid strategy works more efficiently.
Quadratic selection sort is the sorting system that sorts out the smallest value in an entire list and arrange the list in such a way that the smallest value comes first.
Bar-code readers are typically used to track large numbers of inventory items, as in grocery store inventory and checkout, package tracking, warehouse inventory control, and zip code routing for postal mail.
A. True
B. False
which approach does procedural programming follow? bottom up, top down, random, or object oriented
Answer:
Top to down approach
Explanation:
3. Explain why the process of project planning is iterative and
why a plan must be continually reviewed during a software
project.
Ans:
Answer:
because they inspecting or checking how there works good or not good there are under there work what a result cause they want a good and beautiful work
They're inspecting or checking how there works good or not good there are beneath there job what a result because they want a nice and beautiful work.
What is project planning?The discipline of project planning focuses on how to complete a project within a predetermined timeframe, often with predetermined stages and resources. According to one method of project planning, the first stage is to set definable goals. scheduling the deliverables definition.
A project plan is made in order to effectively provide a result for the internal or external client. Project deliverables include, for instance, software products, design documentation, and other assets listed in the project plan. Deliverables for projects are frequently asked for as software products.
A project plan is a group of official documents that describe the execution and control phases of the project. The strategy considers risk management, resource management, and communications in addition to scope, cost, and schedule baselines.
Thus, They're inspecting or checking how there works good or not good.
For more information about project planning, click here:
https://brainly.com/question/27992266
#SPJ2
The penalties for ignoring the requirements for protecting classified information when using social networking services are _________________ when using other media and methods of dissemination.
The penalties for ignoring the requirements for protecting classified information when using social networking services are the same when using other media and methods of dissemination.
The penalties are the same because it does not matter what the medium used, the effect is that classified information and confidential details have been left unguarded and exposed.
When in hold of such information, it is not okay to leave it unguarded or exposed. A person who is found guilty of disclosure of classified materials would face sanctions such as:
They would be given criminal sanctionsThey would face administrative sanctionsThey would also face civil litigationsRead more on https://brainly.com/question/17207229?referrer=searchResults
Describe how asymmetric encryption is used to send a message from User A to User B that assures data confidentiality, authentication, and integrity. Be specific as to the keys used and how they achieve the three goals.
Answer:
Find the explanation below.
Explanation:
Asymmetric encryption is a system of communication in technology between two parties where keys which are variable values coined by an algorithm are used to encrypt and decrypt the messages between the sender and receiver. The two types of keys used in this process are the public and private keys. The public keys can be used by anyone to encrypt messages which are then sent to the receiver who decrypts the message using his private keys. The private keys on the other hand are only shared by the person who first set up the key. In sending messages this way, the receiver's public key is gotten from a public directory, and the message encrypted by the sender. The receiver can then decrypt the message using his private keys. But if the message is encrypted using a private key, it is decrypted by the receiver with a public key.
The one-way nature of this style of communication ensures data integrity and confidentiality since users are not required to disclose their keys and only the two parties can access the message. The two end users also preserve the right to authenticate the keys. The transport layer security protocol makes use of asymmetric encryption.
The breastbone or ________________ extends down the chest.
Answer:
The sternum or breastbone is a long flat bone located in the central part of the chest.
The sternum or breastbone is a long flat bone located in the central part of the chest.
In the middle of the chest, there is a long, flat bone known as the sternum or breastbone. It forms the front of the rib cage and is joined to the ribs by cartilage, assisting in the protection of the heart, lungs, and major blood arteries from harm. It is one of the longest and largest flat bones in the body, somewhat resembling a necktie. The manubrium, body, and xiphoid process are its three regions.
Therefore, the sternum or breastbone is a long flat bone located in the central part of the chest.
Learn more about the breastbone here:
https://brainly.com/question/32917871.
#SPJ2
You are required to install a printer on a Windows 7 Professional x86 workstation. Which print driver do you need to complete the installation?
Answer:
It depends on the model of the printer you want to install. Recent printers when connected to the computer install themselves searching for the drivers needed on the internet. Anyway, you can always google the word "driver" plus the model of your printer and it will surely appear the driver you need from the the company's website of the printer
The print driver that you will need to complete the installation of a printer on Windows 7 Professional x86 workstation is; 32 bit driver
In windows 7 Professional, an x86 name architecture simply denotes a 32 - bit CPU and operating system while x64 will refer to a 64-bit CPU and operating system.
Thus, since we want to install a printer on a Windows 7 Professional x86 workstation, it means we have to use a print driver that is 32 - bit.
Read more about 32 bits at; https://brainly.com/question/19667078
Q2) Answer the following:
1- Expression d=i++; causes:
a. The value of i incremented by 1
b- The value of i assigned to d
C- The value of i assigned to d then i incremented by 1
d- The value ol i incremented by 1 then assigned to d.
CO
SA
Answer:
D
Explanation:
The value of i is incremented by one then assigned to d
Your car must have two red stoplights, seen from ______ feet in the daytime, that must come on when the foot brake is pressed.
A. 100
B. 200
C. 300
D. 400
Answer:
the answer is 300 feet in the daytime
An organization is building a new customer services team, and the manager needs to keep the team focused on customer issues and minimize distractions. The users have a specific set of tools installed, which they must use to perform their duties. Other tools are not permitted for compliance and tracking purposes. Team members have access to the Internet for product lookups and to research customer issues. Which of the following should a security engineer employ to fulfill the requirements for the manager?a. Install a web application firewallb. Install HIPS on the team's workstations.c. implement containerization on the workstationsd. Configure whitelisting for the team
Answer:
a
Explanation:
because they need to protect the organization's information
list three components of a computer system
Consider two different implementations of the same instruction set architecture (ISA). The instructions can be divided into four classes according to their CPI (class A, B, C, and D). P1 with a clock rate of 2.5 GHz have CPIs of 1, 2, 3, and 3 for each class, respectively. P2 with a clock rate of 3 GHz and CPIs of 2, 2, 2, and 2 for each class, respectively. Given a program with a dynamic instruction count of 1,000,000 instructions divided into classes as follows: 10% class A, 20% class B, 50% class C, and 20% class D.which implementation is faster?
a. What is the global CPI for each implementation?
b. Find the clock cycles required in both cases.
Answer: Find answers in the attachments
Explanation:
how do you run a function in python?
5.15 LAB: Count input length without spaces, periods, or commas Given a line of text as input, output the number of characters excluding spaces, periods, or commas. Ex: If the input is:
Answer:
Following are the code to this question:
userVal = input()#defining a variable userVal for input the value
x= 0#defining variable x that holds a value 0
for j in userVal:#defining for loop to count input value in number
if not(j in " .,"):#defining if block that checks there is no spaces,periods,and commas in the value
x += 1#increment the value of x by 1
print(x)#Print x variable value
Output:
Hello, My name is Alex.
17
Explanation:
In the above-given code, a variable "userVal" is defined that uses the input method for input the value from the user end, in the next line, an integer variable "x" is defined, hold value, that is 0, in this variable, we count all values.
In the next line, for loop is defined that counts string value in number and inside the loop an if block is defined, that uses the not method to remove spaces, periods, and commas from the value and increment the value of x by 1. In the last step, the print method is used, which prints the calculated value of the "x" variable.
Answer:
Explanation:#include <iostream>
#include<string>
using namespace std;
int main()
{
string str;
cout<<"Enter String \n";
getline(cin,str);/* getLine() function get the complete lines, however, if you are getting string without this function, you may lose date after space*/
//cin>>str;
int count = 0;// count the number of characeter
for (int i = 1; i <= str.size(); i++)//go through one by one character
{
if ((str[i]!=32)&&(str[i]!=44)&&(str[i]!=46))//do not count period, comma or space
{
++ count;//count the number of character
}
}
cout << "Number of characters are = "; //display
cout << count;// total number of character in string.
return 0;
}
}
Write the program to compute how many gallons of paint are needed to cover the given square feet of walls. Assume 1 gallon can cover 350.0 square feet. So gallons =the square feet divided by 350.0. If the input is 250.0, the output should be: 0.714285714286
Answer:
Here is the Python and C++ program.
Python program:
gallons_paint=0.0 #declare and initialize gallons_paint
wall_area = float(input()) #prompts user to enter wall area
gallons_paint = wall_area / 350 #formula to compute gallons of paint needed to cover the given square feet of walls
print(gallons_paint) #display the result
C++ program:
#include <iostream> //to use input output functions
using namespace std; //to identify objects like cin cout
int main(){ //start of main() function body
float wall_area,gallons_paint=0; //declare variables
cin>>wall_area; //reads input wall area from user
gallons_paint=wall_area/350; //formula to compute gallons of paint needed to cover the given square feet of walls
cout<<gallons_paint;} //print the result
Explanation:
The program prompts the user to enter the area of wall and stores the input value in wall_area
Suppose the user enters 250 as wall area
The the formula gallons_paint=wall_area/350; works as follows:
gallons_paint = wall_area/350;
= 250/350
= 0.71428
gallons_paint = 0.71428
So the output is:
0.71428
The screenshot of the program along with its output is attached.
Ann. An employee in the payroll department, has contacted the help desk citing multiple issues with her device, including: Slow performance Word documents, PDFs, and images no longer opening A pop-up Ann states the issues began after she opened an invoice that a vendor emailed to her. Upon opening the invoice, she had to click several security warnings to view it in her word processor. With which of the following is the device MOST likely infected?
a. Spyware
b. Crypto-malware
c. Rootkit
d. Backdoor
Answer:
d. Backdoor
Explanation:
A backdoor is a type of malware that overrides security checks and authentications to access a computer or embedded device.
When this is done, remote access is granted and databases and servers can be accessed and modified. Attackers can also give remote commands to the system.
What happened to Ann in the payroll department is probably a backdoor attack that affected her device.
b. Does “refactoring” mean that you modify the entire design iteratively? If not, what does it mean?
Explanation:
Refactoring consists of improving the internal structure of an existing program's source code, while preserving its external behavior.
Giving Brainliest IFFF CORRECT
Jonathan needs to create a chart that shows the change in weight he can lift in weightlifting class. Which chart or graph should he use?
Bar graph
Column chart
Line graph
Pie chart
Answer:
line graph
Explanation:
the change in weight is linear
Answer:
Line Graph
Explanation:
Linear Weight change
Although Python provides us with many list methods, it is good practice and very instructive to think about how they are implemented. Implement a Python methods that works like the following: a. count b. in: return True if the item is in the list c. reverse d. index: return -1 if the item is not in the list e. insert
Answer:
Here are the methods:
a) count
def count(object, list):
counter = 0
for i in list:
if i == object:
counter = counter + 1
return counter
b) in : return True if the item is in the list
def include(object, list):
for i in list:
if i == object:
return True
return False
c) reverse
def reverse(list):
first = 0
last = len(list)-1
while first<last:
list[first] , list[last] = list[last] , list[first]
first = first + 1
last = last - 1
return list
d) index: return -1 if the item is not in the list
def index(object, list):
for x in range(len(list)):
if list[x] == object:
return x
return -1
e) insert
def insert(object, index, list):
return list[:index] + [object] + list[index:]
Explanation:
a)
The method count takes object and a list as parameters and returns the number of times that object appears in the list.
counter variable is used to count the number of times object appears in list.
Suppose
list = [1,1,2,1,3,4,4,5,6]
object = 1
The for loop i.e. for i in list iterates through each item in the list
if condition if i == object inside for loop checks if the item of list at i-th position is equal to the object. So for the above example, this condition checks if 1 is present in the list. If this condition evaluates to true then the value of counter is incremented to 1 otherwise the loop keeps iterating through the list searching for the occurrence of object (1) in the list.
After the complete list is moved through, the return counter statement returns the number of times object (i.e. 1 in the example) occurred in the list ( i.e. [1,1,2,1,3,4,4,5,6] ) As 1 appears thrice in the list so the output is 3.
b)
The method include takes two parameters i.e. object and list as parameters and returns True if the object is present in the list otherwise returns False. Here i have not named the function as in because in is a reserved keyword in Python so i used include as method name.
For example if list = [1,2,3,4] and object = 3
for loop for i in list iterates through each item of the list and the if condition if i == object checks if the item at i-th position of the list is equal to the specified object. This means for the above example the loop iterates through each number in the list and checks if the number at i-th position in the list is equal to 3 (object). When this if condition evaluates to true, the method returns True as output otherwise returns False in output ( if 3 is not found in the list). As object 3 is present in the list so the output is True.
c) reverse method takes a list as parameter and returns the list in reverse order.
Suppose list = [1,2,3,4,5,6]
The function has two variables i.e. first that is the first item of the list and last which is the last item of the list. Value of first is initialized to 0 and value of last is initialized to len(list)-1 where len(list) = 6 and 6-1=5 so last=5 for the above example. These are basically used as index variables to point to the first and last items of list.
The while loop executes until the value of first exceeds that of last.
Inside the while loop the statement list[first] , list[last] = list[last] , list[first] interchanges the values of elements of the list which are positioned at first and last. After each interchange the first is incremented to 1 and last is decremented to 1.
For example at first iteration:
first = 0
last = 5
list[0] , list[5] = list[5] , list[0]
This means in the list [1,2,3,4,5,6] The first element 1 is interchanged with last element 6. Then the value of first is incremented and first = 1, last = 4 to point at the elements 2 and 5 of the list and then exchanges them too.
This process goes on until while condition evaluates to false. When the loop breaks statement return list returns the reversed list.
d) The method index takes object and list as parameters and returns the index of the object/item if it is found in the list otherwise returns -1
For example list = [1,2,4,5,6] and object = 3
for loop i.e. for x in range(len(list)): moves through each item of the list until the end of the list is reached. if statement if list[x] == object: checks if the x-th index of the list is equal to the object. If it is true returns the index position of the list where the object is found otherwise returns -1. For the above examples 3 is not in the list so the output is -1
e) insert
The insert function takes as argument the object to be inserted, the index where the object is to be inserted and the list in which the object is to be inserted.
For example list = [0, 1, 2, 4, 5, 6] and object = 3 and index = 3
3 is to be inserted in list [1,2,4,5] at index position 3 of the list. The statement:
return list[:index] + [object] + list[index:]
list[:index] is a sub list that contains items from start to the index position. For above example:
list[:index] = [0, 1, 2]
list[index:] is a sub list that contains items from index position to end of the list.
list[index:] = [4, 5, 6]
[object] = [3]
So above statement becomes:
[0, 1, 2] + [3] + [4, 5, 6]
So the output is:
[0, 1, 2, 3, 4, 5, 6]
3. What are the first steps that you should take if you are unable to get onto the Internet? (1 point)
O Check your router connections then restart your router.
O Plug the CPU to a power source and reboot the computer.
O Adjust the display properties and check the resolution
Use the Control Panel to adjust the router settings.
Answer:
Check your router connections then restart your router.
Explanation:
When the internet connection is not displaying properly then the first step is to check the router. The network icon on the internet displays the availability of internet. Adjust the router and see if the router is working properly. If not restart the router so that it adjusts its settings to default. The connection will be available on the computer and internet will start working normally.