Lists are used in Python to hold multiple values in one variable
(a) Nested list
A nested list is simply a list of list; i.e. a list that contains another list.
It is also called a 2 dimensional list.
An example is:
nested_list = [[ 1, 2, 3, 4] , [ 5, 6, 7]]
(b) The “*” operator
The "*" operator is used to calculate the product of numerical values.
An example is:
num1 = num2 * num3
List slices
This is used to get some parts of a list; it is done using the ":" sign
Take for instance, you want to get the elements from the 3rd to the 5th index of a list
An example is:
firstList = [1, 2 ,3, 4, 5, 6, 7]
secondList = firstList[2:5]
The “+=” operator
This is used to add and assign values to variables
An example is:
num1 = 5
num2 = 3
num2 += num1
A list filter
This is used to return some elements of a list based on certain condition called filter.
An example that prints the even elements of a list is:
firstList = [1, 2 ,3, 4, 5, 6, 7]
print(list(filter(lambda x: x % 2 == 0, firstList)))
A valid but wrong list operation
The following operation is to return a single list, but instead it returns as many lists as possible
def oneList(x, myList=[]):
myList.append(x)
print(myList)
oneList(3)
oneList(4)
Read more about Python listsat:
Answer:
Create a default route on the border router. Check the NAT configuration and network addresses.
Explanation:
The LAN or local area network is a network meant for a small geographic area, ranging from a small home office to office building.
For a LAN to be connected to the internet, it is subscribed to a ISP. The ISP provides the internet/ global WAN resources to the LAN. The border router or stub is configured with a gateway of last resort or default route to route packets to the WAN network and a Network address translation, NAT, is used for a large LAN.
The syntax for default route configuration on the border router is;
Router(config)# IP route 0.0.0.0 0.0.0.0 s0/0/1
crab
b.
web robot
c.
database
d.
runner
Answer: B) Web robot
Explanation:
Web robot or spider is the search engine program which automatically visit the new web site and update the information. Basically, it is the internet bot that helps in store the information from the search engine to the index.
Spider searches the web site and read the information in their given page for creating the entries from search engine.
Web robot is also known as web crawler, this type of programs are use by different search engine that automatically download and update the web content on web sites.
Answer:
1. Get the number
2. Declare a variable to store the sum and set it to 0
3. Repeat the next two steps till the number is not 0
4. Get the rightmost digit of the number with help of remainder ‘%’ operator by dividing it with 10 and add it to sum.
5. Divide the number by 10 with help of ‘/’ operator
6. Print or return the sum
# include<iostream>
using namespace std;
/* Function to get sum of digits */
class gfg
{
public:
int getSum(float n)
{
float sum = 0 ;
while (n != 0)
{
sum = sum + n % 10;
n = n/10;
}
return sum;
}
};
//driver code
int main()
{
gfg g;
float n = 687;
cout<< g.getSum(n);
return 0;
}
Explanation:
hey hi Mark hi mark
the console output is:
hey 1
hi 2
Mark 1
hi 2
mark 1
Answer:
JavaScript code is given below
Explanation:
function calcWordFrequencies() {
var words = prompt("Enter the sentence below").split(" ");
var unique_words = [], freqencies = [], count = 0;
for (var i = 0; i < words.length; i++) {
var found = false;
for (var j = 0; j < count; j++) {
if (words[i] === unique_words[j]) {
freqencies[j] = freqencies[j] + 1;
found = true;
}
}
if (!found) {
unique_words[count] = words[i];
freqencies[count] = 1;
count++;
}
}
for (var i = 0; i < words.length; i++) {
var result = 0;
for (var j = 0; j < count; j++) {
if (words[i] === unique_words[j]) {
result = freqencies[j];
break;
}
}
console.log(words[i] + " " + result);
}
}
Answer:
The execution resumes in the finally block if one exists or otherwise from the next statement following the try...catch block.
Explanation:
Once an exception has been thrown and caught in the code, the execution continues with the statements in the finally block if one exists. If there is no finally block defined then execution resumes from the next statement following the try... catch block. For example:
try{
//An exception is raised
}
catch (Exception e){
//Exception is handled
}
System.out.println("After try...catch");
In this code segment, the next statement to be executed after catch is the System.out.println();