Answer:Polymorphic Virus
Explanation:
Malware that can change its signature each time is polymorphic
what are the 21St century competencies or skills required in the information society?
Answer:
Communication
Collaboration
ICT literacy
Explanation:
These are some of the skills that are needed in the 21st century to compete and thrive in the information society.
To remain progressive, one needs to have good communication skills. These communication skills can include Active Listening and Passive Listening.
Collaboration is important because you'll have to work with other people as no man is an island, we need someone else so the skill of collaboration is necessary to compete and stay relevant in the information society in the 21st century.
IT literacy is also very important because one needs to have basic computer knowledge such as programming, computer essentials and applications, etc.
Declare a class named PatientData that contains two attributes named height_inches and weight_pounds. Sample output for the given program with inputs: 63 115 Patient data (before): 0 in, 0 lbs Patient data (after): 63 in, 115 lbs 1 Your solution goes here ' 2 1 test passed 4 patient PatientData () 5 print('Patient data (before):, end-' ') 6 print(patient.height_inches, 'in,, end=' ') 7 print(patient.weight_pounds, lbs') All tests passed 9 10 patient.height_inches = int(input()) 11 patient.weight_pounds = int(input()) 12 13 print('Patient data (after):', end-' ') 14 print (patient. height_inches, 'in,', end- ') 15 print(patient.weight_pounds, 'lbs') Run
Answer:
class PatientData(): #declaration of PatientData class
height_inches=0 #attribute of class is declared and initialized to 0
weight_pounds=0 #attribute of class is declared and initialized to 0
Explanation:
Here is the complete program:
#below is the class PatientData() that has two attributes height_inches and weight_pounds and both are initialized to 0
class PatientData():
height_inches=0
weight_pounds=0
patient = PatientData() #patient object is created of class PatientData
#below are the print statements that will be displayed on output screen to show that patient data before
print('Patient data (before):', end=' ')
print(patient.height_inches, 'in,', end=' ')
print(patient.weight_pounds, 'lbs')
#below print statement for taking the values height_inches and weight_pounds as input from user
patient.height_inches = int(input())
patient.weight_pounds = int(input())
#below are the print statements that will be displayed on output screen to show that patient data after with the values of height_inches and weight_pounds input by the user
print('Patient data (after):', end=' ')
print(patient.height_inches, 'in,', end=' ')
print(patient.weight_pounds, 'lbs')
Another way to write the solution is:
def __init__(self):
self.height_inches = 0
self.weight_pounds = 0
self keyword is the keyword which is used to easily access all the attributes i.e. height_inches and weight_pounds defined within a PatientData class.
__init__ is a constructor which is called when an instance is created from the PatientData, and access is required to initialize the attributes height_inches and weight_pounds of PatientData class.
The program along with its output is attached.
In this exercise we have to use the knowledge of computational language in python to describe a code, like this:
The code can be found in the attached image.
To make it easier the code can be found below as:
class PatientData():
height_inches=0
weight_pounds=0
patient = PatientData()
print('Patient data (before):', end=' ')
print(patient.height_inches, 'in,', end=' ')
print(patient.weight_pounds, 'lbs')
patient.height_inches = int(input())
patient.weight_pounds = int(input())
print('Patient data (after):', end=' ')
print(patient.height_inches, 'in,', end=' ')
print(patient.weight_pounds, 'lbs')
See more about python at brainly.com/question/26104476
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
Add each element in origList with the corresponding value in offsetAmount. Print each sum followed by a space. Ex: If origList = {40, 50, 60, 70} and offsetAmount = {5, 7, 3, 0}, print:45 57 63 70 #include using namespace std;int main() {const int NUM_VALS = 4;int origList[NUM_VALS];int offsetAmount[NUM_VALS];int i = 0;origList[0] = 40;origList[1] = 50;origList[2] = 60;origList[3] = 70;offsetAmount[0] = 5;offsetAmount[1] = 7;offsetAmount[2] = 3;offsetAmount[3] = 0;// your solution goes here
Answer:
Complete the program with the following code segment
for(int i =0;i<=3;i++)
{
cout<<offsetAmount[i]+origList[i]<<" ";
}
return 0;
}
Explanation:
The following line is an iteration of variable i from 1 to 3; It iterates through elements of origList and offsetAmount
for(int i =0;i<=3;i++){
This adds and prints the corresponding elements of origList and offsetAmount
cout<<offsetAmount[i]+origList[i]<<" ";
} The iteration ends here
A device driver would ordinarily be written in :__________
a. machine language
b. assembly language
c. a platform-independent language, such as Java
d. an application-oriented language
Answer: Assembly language
Explanation:
A device driver is a computer program that is in charge of the operation or the controls of a device attached to a computer.
device driver would ordinarily be written in an assembly language. Assembly language is a low-level symbolic code that is converted by an assembler. It is typically designed for a particular type of processor.
Write a program that asks the user to enter a series of numbers separated by commas. Here is an example of valid input: 7,9,10,2,18,6 The program should calculate and display the sum of all the numbers.
Answer:
Here is the JAVA program. Let me know if you need the program in some other programming language.
import java.util.Scanner; // used for taking input from user
public class Main{ //Main class
public static void main(String[] args) {//start of main() function body
Scanner scan = new Scanner(System.in); // creates a Scanner type object
String input; // stores input series
int sum = 0; //stores the sum of the series
System.out.println("Enter a series of numbers separated by commas: "); //prompts user to enter a series of numbers separated by comma
input = scan.nextLine(); //reads entire input series
String[] numbers = input.split("[, ]"); //breaks the input series based on delimiter i.e. comma and stores the split sub strings (numbers) into the numbers array
for (int i = 0; i < numbers.length; i++) { //loops through each element of numbers array until the length of the numbers reaches
sum += Integer.parseInt(numbers[i]); } // parses the each String element of numbers array as a signed decimal integer object and takes the sum of all the integer objects
System.out.println("Sum of all the numbers: " + sum); } } //displays the sum of all the numbers
Explanation:
The program prompts the user to enter a series separated by commas.
Then split() method is used to split or break the series of numbers which are in String form, into sub strings based on comma (,) . This means the series is split into separate numbers. These are stored in numbers[] array.
Next the for loop iterate through each sub string i.e. each number of the series, converts each String type decimal number to integer using Integer.parseInt and computes the sum of all these integers. The last print statement displays the sum of all numbers in series.
If the input is 7,9,10,2,18,6
Then the output is: 7+9+10+2+18+6
sum = 52
The program and its output is attached.
You are the network administrator for your company. A user reports that he cannot access network resources from his computer. He was able to access the resources yesterday. While troubleshooting his computer, you find that his computer is issued an Automatic Private IP Addressing (APIPA) address. All the network equipment in the user's computer is functioning properly because you are able to access the user's computer from a remote computer. What is most likely the problem
Answer:
the issued Automatic Private IP Addressing (APIPA) address.
Explanation:
Since we are told that the user was able to access the network resources yesterday, and all the network equipment in the user's computer is functioning properly, there is a very high possibility that because the user's computer has been issued an Automatic Private IP Addressing (APIPA) address, it affected his computer's ability to connect to a public network.
This is the case because private network IP addresses are known to prevent inflow and outflow of data onto public networks.
what are 3 important reasons to reconcile bank and credit card accounts at set dates?
Answer:
To verify transactions have the correct date assigned to them.
To verify that an account balance is within its credit limit.
To verify that all transactions have been recorded for the period.
Explanation:
While interoperability and unrestricted connectivity is an important trend in networking, the reality is that many diverse systems with different hardware and software exist. Programming that serves to "glue together" or mediate between two separate and usually already existing programs is known as:
Answer:
Middleware
Explanation:
In today's technology like networking, software development, web development, etc, there is a need for connectivity. The problem at hand is the variation of the tech brands which results in the difference in operating systems, applications, and connectivity protocols. This problem is solved with the introduction of Middleware.
Middleware is the solution to conflicting software applications, interconnectivity between various tech platforms. It promotes cross-platform interactions.
Define Proportional spacing fornt.
Answer:
Alphabetic character spacing based on the width of each letter in a font. ... Proportional spacing is commonly used for almost all text. In this encyclopedia, the default text is a proportional typeface, and tables are "monospaced," in which all characters have the same fixed width.
hope this answer helps u
pls mark me as brainlitest .-.
If you implement too many security controls, what portion of the CIA triad (Information Assurance Pyramid) may suffer?
a. Availability
b. Confidentiality
c. Integrity
d. All of the above
Answer:
Option A
Availability
Explanation:
The implementation of too many security protocols will lead to a reduction of the ease at which a piece of information is accessible. Accessing the piece of information will become hard even for legitimate users.
The security protocols used should not be few, however, they should be just adequate to maintain the necessary level of confidentiality and integrity that the piece of information should have, While ensuring that the legitimate users can still access it without much difficulty.
If our HMap implementation is used (load factor of 75% and an initial capacity of 1,000), how many times is the enlarge method called if the number of unique entries put into the map is:_______
a. 100
b. 750
c. 2,000
d. 10,000
e. 100,000
Answer:
A) for 100 : < 1 times
b) for 750 : < 1 times
c) For 2000 = 1 time
D) for 10000 = 4 times
E) for 100000 = 7 times
Explanation:
Given data:
load factor = 75%
initial capacity = 1000
The number of times the enlarge method will be called for a unique number of entries would be 2 times the initial capacity ( 1000 ) because the load factor = 75% = 0.75
A) for 100 : < 1 times
b) for 750 : < 1 times
C) For 2000
= initial capacity * 2 = 2000 ( 1 time )
D) for 10000
= 1000 * 2 *2 *2*2 = 16000 ( 4 times )
to make it 10000 we have to add another 2000 which will make the number of times = 4 times
E)for 100000
= 1000*2*2*2*2*2*2*2= 128000 ( 7 times )
unique entry of 100000 is contained in 7 times
Which recovery method helps users boot into an environment to get them back into the system so they can begin the troubleshooting process
Answer:
sfadasda
Explanation:
dsadasdadas
Write a CashRegister class that can be used with the RetailItem class that you wrote in Chapter 6's Programming Challenge 4. The CashRegister class should simulate the sale of a retail item. It should have a constructor that accepts a RetailItem object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. In addition, the class should have the following methods:
• The getSubtotal method should return the subtotal of the sale, which is the quantity multiplied by the price. This method must get the price from the RetailItem object that was passed as an argument to the constructor.
• The getTax method should return the amount of sales tax on the purchase. The sales tax rate is 6 percent of a retail sale.
• The getTotal method should return the total of the sale, which is the subtotal plus the sales tax.
Demonstrate the class in a program that asks the user for the quantity of items being purchased and then displays the sale’s subtotal, amount of sales tax and total.
Answer:
Following are the code to this question:
import java.util.*; //import package for user input
class RetailItem//defining class RetailItem
{
private String desc;//defining String variable
private int unit;//defining integer variable
private double prices;//defining double variable
RetailItem()//defining default Constructor
{
//Constructor body
}
Output:
The Sub Total value: 199.75
The Sales Tax value: 11.985
The Total value: $211.735
Explanation:
In the above code three class "RetailItem, CashRegister, and Main" is defined, in the class "RetailItem", it defines three variable that is "desc, unit, and prices", inside the class "get and set" method and the constructor is defined, that calculates its value.
In the next step, class "CashRegister" is defined, and inside the class parameterized constructor is defined, which uses the get and set method to return its value.
In the next step, the main class is declared, in the main method two-class object is created and calls its method that are "getSubtotal, getTax, and getTotal".
There is some technical error that's why full code can't be added so, please find the attached file of code.
g Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argument is "gravity" the method should display -"ytivarg". Demonstrate the method in a program that asks the user to input a string and then passes it to the method.
Answer:
The program written in C++ is as follows; (See Explanation Section for explanation)
#include <iostream>
using namespace std;
void revstring(string word)
{
string stringreverse = "";
for(int i = word.length() - 1; i>=0; i--)
{
stringreverse+=word[i];
}
cout<<stringreverse;
}
int main()
{
string user_input;
cout << "Enter a string: ";
getline (std::cin, user_input);
getstring(user_input);
return 0;
}
Explanation:
The method starts here
void getstring(string word)
{
This line initializes a string variable to an empty string
string stringreverse = "";
This iteration iterates through the character of the user input from the last to the first
for(int i = word.length() - 1; i>=0; i--) {
stringreverse+=word[i];
}
This line prints the reversed string
cout<<stringreverse;
}
The main method starts here
int main()
{
This line declares a string variable for user input
string user_input;
This line prompts the user for input
cout << "Enter a string: ";
This line gets user input
getline (std::cin, user_input);
This line passes the input string to the method
revstring(user_input);
return 0;
}
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:
What is the science and art of making an illustrated map or chart. GIS allows users to interpret, analyze, and visualize data in different ways that reveal patterns and trends in the form of reports, charts, and maps? a. Automatic vehicle locationb. Geographic information systemc. Cartographyd. Edge matching
Answer:
c. Cartography.
Explanation:
Cartography is the science and art of making an illustrated map or chart. Geographic information system (GIS) allows users to interpret, analyze, and visualize data in different ways that reveal patterns and trends in the form of reports, charts, and maps.
Basically, cartography is the science and art of depicting a geographical area graphically, mostly on flat surfaces or media like maps or charts. It is an ancient art that was peculiar to the fishing and hunting geographical regions. Geographic information system is an improved and technological form of cartography used for performing a whole lot of activities or functions on data generated from different locations of the Earth.
Answer:
C. Cartography
Explanation:
Which octet of the subnet mask 255.255.255.0 will tell the router the corresponding host ID?The last octetThe first octetThe first and last octetThe middle two octets
Answer:
The last octet
Explanation:
Here in the question, given the sub net mask, we want to know which octet of the subnet mask will tell the router the corresponding host ID.
The correct answer to this is the last octet. It is the last octet that will tell the router the corresponding host ID
list three components of a computer system
Write an interactive program to calculate the volume and surface area of a three-dimensional object.
Answer:
I am writing a Python program:
pi=3.14 #the value of pi is set to 3.14
radius = float(input("Enter the radius of sphere: ")) #prompts user to enter the radius of sphere
surface_area = 4 * pi * radius **2 #computes surface area of sphere
volume = (4.0/3.0) * (pi * radius ** 3) #computes volume of sphere
print("Surface Area of sphere is: ", surface_area) #prints the surface area
print("Volume of sphere is: {:.2f}".format(volume)) #prints the volume
Explanation:
Please see the attachment for the complete interactive code.
The first three lines of print statement in the attached image give a brief description of the program.
Next the program assigns 3.14 as the value of π (pi). Then the program prompts the user to enter the radius. Then it computes the surface area and volume of sphere using the formulas. Then it prints the resultant values of surface area and volume on output screen.
The psuedocode for this program is given below:
PROGRAM SphereVolume
pi=3.14
NUMBER radius, surface_area, volume
INPUT radius
COMPUTE volume = (4/3) * pi* radius ^3
COMPUTE surface_area = 4 * pi * radius ^ 2
OUTPUT volume , surface_area
END
I keep getting this error: postfix.cpp: In function ‘double RPN_evaluation(std::string)’: postfix.cpp:42:26: error: cannot convert ‘__gnu_cxx::__alloc_traits > >::value_type {aka std::basic_string }’ to ‘char’ for argument ‘1’ to ‘int isOperand(char)’ if(isOperand(expr.at(g))){ ^ postfix.cpp:96:1: warning: control reaches end of non-void function [-Wreturn-type] } I am not sure what I am doing wrong, help please
Answer:
expr.at(g) returns a string, not a char. They are not the same thing and that is what the compiler is complaining about.
Which wireless device connects multiple laptops, tablets, phones, and other mobile devices in a corporate environment?
Answer:
Bluetooth or a wifi router or a gateway
Explanation:
PROGRAM 8: Grade Converter! For this program, I would like you to create a function which returns a character value based on a floating point value as
Answer:
This function will return a character grade for every floating-point grade for every student in the class.
function grade( floatPoint ){
let text;
switch ( floatPoint ) {
case floatPoint < 40.0 :
text= " F ";
break;
case floatPoint == 40.0 :
text= " P ";
break;
case floatPoint > 40.0 && floatPoint <= 50.0 :
text= " C ";
break;
case floatPoint > 50.0 && floatPoint < 70.0 :
text= " B ";
break;
case floatPoint >=70.0 && floatPoint <= 100.0 :
text= " C ";
break;
default :
text= "Floating point must be between 0.0 to 100.0"
}
return text;
}
Explanation:
This javascript function would return a character grade for floating-point numbers within the range of 0.0 to 100.0.
Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot. Sample output with inputs: 58 Total inches: 68 def print_total_inches (num_feet, hum_inches): 2 str1=12 str2=num_inches 4 print("Total inches:',(num_feet*strl+str2)) 5 print_total_inches (5,8) 6 feet = int(input) 7 inches = int(input) 8 print_total_inches (feet, inches)
I'll pick up your question from here:
Define a function print_total_inches, with parameters num_feet and num_inches, that prints the total number of inches. Note: There are 12 inches in a foot.
Sample output with inputs: 5 8
Total inches: 68
Answer:
The program is as follows:
def print_total_inches(num_feet,num_inches):
print("Total Inches: "+str(12 * num_feet + num_inches))
print_total_inches(5,8)
inches = int(input("Inches: "))
feet = int(input("Feet: "))
print_total_inches(feet,inches)
Explanation:
This line defines the function along with the two parameters
def print_total_inches(num_feet,num_inches):
This line calculates and prints the equivalent number of inches
print("Total Inches: "+str(12 * num_feet + num_inches))
The main starts here:
This line tests with the original arguments from the question
print_total_inches(5,8)
The next two lines prompts user for input (inches and feet)
inches = int(input("Inches: "))
feet = int(input("Feet: "))
This line prints the equivalent number of inches depending on the user input
print_total_inches(feet,inches)
Answer:
Written in Python:
def print_total_inches(num_feet,num_inches):
print("Total inches: "+str(12 * num_feet + num_inches))
feet = int(input())
inches = int(input())
print_total_inches(feet, inches)
Explanation:
Write a CREATE VIEW statement that defines a view named InvoiceBasic that returns three columns: VendorName, InvoiceNumber, and InvoiceTotal. Then, write a SELECT statement that returns all of the columns in the view, sorted by VendorName, where the first letter of the vendor name is N, O, or P.
Answer:
CREATE VIEW InvoiceBasic AS
SELECT VendorName, InvoiceNumber, InvoiceTotal
FROM Invoices JOIN Vendors ON Invoices.InvoiceID = Vendors.VendorID
WHERE left(VendorName,1) IN ('N' , 'O ' , 'P' )
Explanation:
CREATE VIEW creates a view named InvoiceBasic
SELECT statements selects columns VendorName, InvoiceNumber and InvoiceTotal from Invoices table
JOIN is used to combine rows from Invoices and Vendors table, based on a InvoiceID and VendorsID columns.
WHERE clause specified a condition that the first letter of the vendor name is N, O, or P. Here left function is used to extract first character of text from a VendorName column.
А.
is the highest education degree available at a community college.
Answer:
The answer is "associate".
Explanation:
The two-year post-school degree is also known as the associate degree, in which the students pursuing any of this degree, which may take as little as 2 years to complete the course, although many prefer to do it at the same rate. Its first two years of a Bachelor (fresh and sophomore years) were covered by an Associate degree.
10.7 LAB: Fat-burning heart rate Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to
Answer:
I've written in python
Explanation:
age = int(input("Enter the person's age: ")
def fat_burning_heart_rate(x):
rate =( 70/100 * 220 ) - age
print(fat_burning_heart_rate(age))
The program to check the highEst of n numbercan be done by ......,..
Answer: Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548, 60}, the arrangement 6054854654 gives the largest value. And if the given numbers are {1, 34, 3, 98, 9, 76, 45, 4}, then the arrangement 998764543431 gives the largest value.
Explanation: If you need more help follow me on istagram at dr.darrien
-thank you
Which of the following is true about sorting functions?
A. The most optimal partitioning policy for quicksort on an array we know nothing about would be selecting a random element in the array.
B. The fastest possible comparison sort has a worst case no better than O(n log n)
C. Heapsort is usually best when you need a stable sort.
D. Sorting an already sorted array of size n with quicksort takes O(n log n) time.
E. When sorting elements that are expensive to copy, it is generally best to use merge sort.
F. None of the above statements is true.
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.
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]