Python questions 1Which expression correctly removes all emp

Python questions.

1.Which expression correctly removes all empty strings from a list of strings text?

[s.notempty() for s in text]

[len(s)>0 for s in text]

[s for s in text if s]

2. Variable data is a list. Which of the following code fragments produce the same value of the variable result? (Select both.)

i = 0; result = []
while i < len(data):
if data[i].foobar() == True:
print(data[i])
i += 1

[item for item in data if item.foobar()]

result = 0
for item in data:
if item.foobar() == True:
result += item

result = []
for item in data:
if item.foobar():
result.append(item)

3. Which of the following can be X in the following code fragment? (Check all that apply.)

for foo in X:
  bar(foo)

tuple()

bool()

int()

list()

str()

[s.notempty() for s in text]

[len(s)>0 for s in text]

[s for s in text if s]

2. Variable data is a list. Which of the following code fragments produce the same value of the variable result? (Select both.)

i = 0; result = []
while i < len(data):
if data[i].foobar() == True:
print(data[i])
i += 1

[item for item in data if item.foobar()]

result = 0
for item in data:
if item.foobar() == True:
result += item

result = []
for item in data:
if item.foobar():
result.append(item)

3. Which of the following can be X in the following code fragment? (Check all that apply.)

for foo in X:
  bar(foo)

tuple()

bool()

int()

list()

str()

Solution

#include<iostream>

#include<conio.h>

using namespace std;

// Class Declaration

class prime

{

//Member Varibale Declaration

int a,k,i;

public:

prime(int x)

{

a=x;

}

// Object Creation For Class

void calculate()

{

k=1;

{

for(i=2;i<=a/2;i++)

if(a%i==0)

{

k=0;

break;

}

else

{

k=1;

}

}

}

void show()

{

if(k==1)

cout<<\"\ \"<<a<<\" is Prime Number.\";

else

cout<<\"\ \"<<a<<\" is Not Prime Numbers.\";

}

};

//Main Function

int main()

{

int a;

cout<<\"Enter the Number:\";

cin>>a;

// Object Creation For Class

prime obj(a);

// Call Member Functions

obj.calculate();

obj.show();

getch();

return 0;

}

Python questions. 1.Which expression correctly removes all empty strings from a list of strings text? [s.notempty() for s in text] [len(s)>0 for s in text] [
Python questions. 1.Which expression correctly removes all empty strings from a list of strings text? [s.notempty() for s in text] [len(s)>0 for s in text] [
Python questions. 1.Which expression correctly removes all empty strings from a list of strings text? [s.notempty() for s in text] [len(s)>0 for s in text] [

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site