1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Leviafan [203]
2 years ago
14

What is the value of y when this code executes?

Computers and Technology
1 answer:
Cerrena [4.2K]2 years ago
4 0

Answer:

The operation of 6*x only executes if x is greater or equal to 0, since x=-10 and -10 is less than 0, the operation does not execute. For this reason,  the value of y using this code is None.

Explanation:

In python a function is defined with the syntaxis:  

def function(x):  

the operation to execute (x)

value to return

In this case, the function is foo and the parameter is x:  

def foo(x):

  if x>= 0:

     return 6*x

The code starts by assigning a value to x. Then, the code asks if the value of x is grater or equal to 0, if this condition is meet, then the code returns the value of 6 times x, if not, then the code does not return a value. In this case, x is -10 and this value is not grater or equal to 0. Given that the condition is not met, then the code stops executing and the value of y is none.

You might be interested in
You just recently opened a business that will be selling items on the Internet. You don’ t actually have a physical store that p
Ivanshal [37]

Answer:

Explanation:

Shipping fee is based on the weight of the item purchased

Name of the store- MIMI Electronics

Items sold- Consumer electronics, mobiles phones, laptops, wearable devices, accessories, digital watches etc

Shipping charges-

Weight Shipping fee

0-1 kg $      5.00

1-2 kg $   10.00

2-4 kg $   15.00

4-7 kg $   20.00

7-10 kg $   30.00

10 kg + $   50.00

Shipping fee function

F(x)= 5 for all x [0,1]

F(x)= 10 for all x (1,2]

F(x)= 15 for all x (2,4]

F(x)= 20 for all x (4,7]

F(x)= 30 for all x (7,10]

F(x)= 50 for all x (10,infinity)

shipping charge function is a step function where the steps are mentioned in terms of weight.

Shipping charge could also be determined using a piece wise function where the shipping fee is fixed for each piece and is charged based on number of pieces ordered instead of weight of the order

5 0
2 years ago
Please debug the below code in Java please.
lisabon 2012 [21]

Answer:

Check the explanation

Explanation:

//Bugs are highlighted in bold text

class Invoice

Declarations

private num invoiceNumber

private string customer

private num balanceDue

private num tax

public void setInvoiceNUMBER(num number)

Declarations

num LOW_NUM = 1000

num HIGH_NUM = 9999

if number > HIGH_NUM then

invoiceNumber = 0

else

if number < LOW_NUM then

invoiceNumber = 0

else

invoiceNumber = num

endif

return

public void setCustomer(string cust)

customer = cust

return

public void setBalanceDue(num balance)

//Bug balanceDue is Invoice class varible

//but it is assigned to balance .it gives error

balance = balanceDue

setTax()

return

private void setTax()

Declarations

//Bug TAX_RATE is declared as string

//but assigned a double value

string TAX_RATE = 0.07

tax = tax * TAX_RATE

return

public void displayInvoice()

output "Invoice #", invoiceNumber

output "Customer: ", customer

output "Due: ", balanceDue

output "Tax: ", taxDue

//Bug

//Invoice class has no variable called balance .it should be balanceDue

output "Total ", balance + taxDue

return

endClass

start

Declarations

Invoice inv1

Invoice inv2

Invoice inv3

//Warning

//it gives warning object taken but not initilaized

Invoice inv4

inv1.setInvoiceNumber(1244)

inv1.setCustomer("Brown")

inv1.setBalanceDue(1000.00)

inv1.displayInvoice()

inv2.setInvoiceNumber(77777)

inv2.setCustomer("Jenkins")

inv2.setBalanceDue(2000.00)

inv2.displayInvoice()

inv3.setInvoiceNumber(888)

inv3.setCustomer("Russell")

inv3.setBalanceDue(3000.00)

//Bug

//setTax method of Invioce doesnot take any arguments

inv3.setTax(210.00)

inv3.displayInvoice()

stop

//Here is the complete program in c++

//Run the program using Microsoft visual studio 2010 vc++

#include<iostream>

#include<iomanip>

#include<string>

using namespace std;

class Invoice

{

//class varibales

private:

           int invoiceNumber;

           string customer;

           double balanceDue;

           double tax;

//class methods

public:

           void setCustomer(string cus);

           void displayInvoice();

           void setBalanceDue(double balance);

           void setInvoiceNUMBER(int number);

           void setTax();

};

void Invoice::displayInvoice()

{

cout<< setw(10)<<"Invoice #"<<setw(5)<<invoiceNumber<<endl;

cout<<setw(10)<<"Customer: "<<setw(5)<<customer<<endl;

cout<<setw(10)<<"Due: "<<setw(5)<<balanceDue<<endl;

cout<<setw(10)<<"Tax: "<<setw(5)<<tax<<endl;

//Bug

//Invoice class has no variable called balance .it should be balanceDue

cout<< "Total "<< balanceDue + tax<<endl;

}

void Invoice::setCustomer(string cust)

{

customer = cust;

}

void Invoice::setInvoiceNUMBER(int number)

{

const int LOW_NUM = 1000;

const int HIGH_NUM = 9999;

if( number > HIGH_NUM )

invoiceNumber = 0;

else

if (number < LOW_NUM )

       invoiceNumber = 0;

else

   invoiceNumber = number;

}

void Invoice::setBalanceDue(double balance)

{

balanceDue = balance;

}

void Invoice::setTax()

{

double TAX_RATE = 0.07;

tax = balanceDue * TAX_RATE;

}

int main()

{

Invoice inv1;

Invoice inv2;

Invoice inv3;

inv1.setInvoiceNUMBER(1244);

inv1.setCustomer("Brown");

inv1.setBalanceDue(1000.00);

inv1.setTax();

inv1.displayInvoice();

inv2.setInvoiceNUMBER(77777);

inv2.setCustomer("Jenkins");

inv2.setBalanceDue(2000.00);

inv2.setTax();

inv2.displayInvoice();

inv3.setInvoiceNUMBER(888);

inv3.setCustomer("Russell");

inv3.setBalanceDue(3000.00);

inv3.setTax();

inv3.displayInvoice();

system("pause");

return 0;

}

Kindly check the output image below.

5 0
3 years ago
Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other sou
natulia [17]
Ssfhooiyfbjkoyfvhkodd
6 0
3 years ago
Advantages of a computer​
Bess [88]

Answer:

It eases work.

It is deligent.

It is versatile.

8 0
3 years ago
Which color is considerd to be a cool color?
scZoUnD [109]
It depends on personal tastes and what it's applied on.

For example: I like Blue. I think Blue is cool! But, I also think red is cool, on a sports car. I think it would have to be Red, but thats what I think. The same with orange. Green for a T-Shirt is cool as well!

Remember that if you want to find out what color someone likes, just ask them. Generally though, Red is considered to be cool for most things.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which is an example of an input device?
    15·2 answers
  • To the following is not a network connection LAM MAN SAN WAN
    9·1 answer
  • In your own words explain how to add footer and head in a word doc.
    10·1 answer
  • Aspiring graphic designers can earn a(n) certification for graphic design software, such as Photoshop and Acrobat.
    9·2 answers
  • How many questions have you seen so far other than this one?
    10·2 answers
  • Write an algorithm (pseudo-code) that takes an unsorted list of n integers and outputs a sorted list of all duplicate integers.
    6·1 answer
  • How do you do 3.4.5 Add parentheses for code hs? I need answers please
    15·2 answers
  • Subscribe to my you tube channel to get all your questions answered
    8·1 answer
  • Can you predict what changes will come to data storage in the next decade? 
    12·1 answer
  • in a small town, there are two providers of broadband internet access: a cable company and the phone company. the internet acces
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!