UrbanPro

Take BTech Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Can anyone help me with the below programs: A) which returns orger summary as a list with 2- tuples. Each tuple consists of the order number and the product of the price per items and the quantity. OUTPUT: [ ('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97) ]. 10 INR should be increased in the product if the value of the order is smaller than 100.00 INR. OUTPUT: [ ('34587',163.8),('98762',284.0),(77226',108.85),('88112',84.97) ]

Asked by Last Modified  

24 Answers

Learn BTech Tuition +3 Python Python Anaconda Python Advanced

Follow 7
Answer

Please enter your answer

Build Yourself For The Future

Can't solve because product price is a part of the tuple. Since LIST IS MUTABLE so we can change its elements. We can change the whole tuple because it is an element of the list. As WKT TUPLE IS IMMUTABLE so we can't change its elements.
Comments

BCA, MCA, 11 and 12 computer science Trainer with more then 10 years of experience

Try this: t=l=len(t)t1= for i in range (l): if t<100: t1.append(,t+10)]) else: t1.append(,t)])t=t1 print(t)
Comments

Senior Software Engineer/Java Full Stack Developer.

public class DemoApplication { public static void main(String args) { //SpringApplication.run(DemoApplication.class, args); List<Order> list=new ArrayList(); list.add(new Order("34587", 163.8)); list.add(new Order("98762", 284.0)); list.add(new Order("77226", 98.85)); list.add(new Order("88112",...
read more

public class DemoApplication {

 

public static void main(String[] args) {

//SpringApplication.run(DemoApplication.class, args);

 

List<Order> list=new ArrayList();

list.add(new Order("34587", 163.8));

list.add(new Order("98762", 284.0));

list.add(new Order("77226", 98.85));

list.add(new Order("88112", 74.97));

 

System.out.println("Before Processing List orders :: "+list);

 

int index=-1;

for(Order order: list) {

index++;

if(order.getPrice()<100) {

order.setPrice(order.getPrice()+10);

list.set(index, order);

}

}

 

System.out.println("After processing List orders :: "+list);

 

}

 

}

class Order{

    private String orderNo;

    private double price;

    

    public Order(String orderNo, double price) {

super();

this.orderNo = orderNo;

this.price = price;

}

 

public void setOrderNo(String orderNo){

        this.orderNo=orderNo;

    }

    

    public String getOrderNo(){

        return orderNo;

    }

    

    public void setPrice(double price){

        this.price=price;

        

    }

    

    public double getPrice(){

        return price;

    }

 

@Override

public String toString() {

return "Order [orderNo=" + orderNo + ", price=" + price + "]";

}    

    

}

read less
Comments

I am an entrepreneur and have more than 35 years of experience in the IT industry

Pythonized my previous answer: OUTPUT = oL = oL.extend()OUTPUT = oLprint(OUTPUT)
read more

Pythonized my previous answer:

OUTPUT = [ ('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97) ]

oL = []
oL.extend([(id, price + 10) for id, price in OUTPUT if price < 100.00 or\
                  oL.append((id, price))])
OUTPUT = oL
print(OUTPUT)

read less
Comments

IT Professional with 2 years of experience

Hello Anurag, As per your question, Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples. Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of...
read more

Hello Anurag,

As per your question,

 

Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each

Output:- the updated list of tuples.

Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list.

 

Program:

1) With regular for-loop:

# You might use list(input()) to read list from user input.

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

outputList = []

 

for _tuple in inputList:

if (_tuple[1] < 100):

    outputList.append((_tuple[0], _tuple[1]+10))

else:

  outputList.append((_tuple[0],_tuple[1]))

print('Updated List:',outputList)

 

 

PS: Since tuples are immutable (cannot change it's value further) in python, we used one more list instead of replacing the given input list itself.

 

2) With list-comprehension:- 

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

def getUpdatedList(inputList):

  return [(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]

 

outputList = getUpdatedList(inputTuple)

print(outputList)

 

Or simply,

 

print([(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]) 

 

 

Feel free to ask me any further questions. Happy Coding!!!

 

read less
Comments

IT Professional with 2 years of experience

Hello Anurag, As per your question, Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples. Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of...
read more

Hello Anurag,

As per your question,

 

Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each

Output:- the updated list of tuples.

Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list.

 

Program:

1) With regular for-loop:

# You might use list(input()) to read list from user input.

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

outputList = []

 

for _tuple in inputList:

if (_tuple[1] < 100):

    outputList.append((_tuple[0], _tuple[1]+10))

else:

  outputList.append((_tuple[0],_tuple[1]))

print('Updated List:',outputList)

 

 

PS: Since tuples are immutable (cannot change it's value further) in python, we used one more list instead of replacing the given input list itself.

 

2) With list-comprehension:- 

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

def getUpdatedList(inputList):

  return [(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]

 

outputList = getUpdatedList(inputTuple)

print(outputList)

 

Or simply,

 

print([(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]) 

 

 

Feel free to ask me any further questions. Happy Coding!!!

 

read less
Comments

IT Professional with 2 years of experience

Hello Anurag, As per your query, Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples. Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a,...
read more

Hello Anurag,

As per your query,

Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each

Output:- the updated list of tuples.

Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list.

Program:

1) With regular for-loop:

# You might use list(input()) to read list from user input.

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

outputList = []

 

for _tuple in inputList:

if (_tuple[1] < 100): 

    outputList.append((_tuple[0], _tuple[1]+10))

else:

  outputList.append((_tuple[0],_tuple[1]))

print('Updated List:',outputList)

 

PS: Since tuples are immutable (cannot change it's value further) in python, we used one more list instead of replacing the given input list itself.

 

2) With list-comprehension:- 

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

def getUpdatedList(inputList):

  return [(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]

 

outputList = getUpdatedList(inputTuple)

print(outputList)

 

Or simply,

 

print([(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList])

  

 

Feel free to ask me any further questions. Happy Coding!!!

 

read less
Comments

IT Professional with 2 years of experience

Hello Anurag, As per your query, Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples. Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a,...
read more

Hello Anurag,

As per your query,

Input:- a list of tuples with two values (order-number: string, total-order-cost: float) each

Output:- the updated list of tuples.

Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list.

Program:

1) With regular for-loop:

# You might use list(input()) to read list from user input.

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

outputList = []

 

for _tuple in inputList:

if (_tuple[1] < 100): 

    outputList.append((_tuple[0], _tuple[1]+10))

else:

  outputList.append((_tuple[0],_tuple[1]))

print('Updated List:',outputList)

 

PS: Since tuples are immutable (cannot change it's value further) in python, we used one more list instead of replacing the given input list itself.

 

2) With list-comprehension:- 

inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]

 

def getUpdatedList(inputList):

  return [(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]

 

outputList = getUpdatedList(inputTuple)

print(outputList)

 

Or simply,

 

print([(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList])

  

 

Feel free to ask me any further questions. Happy Coding!!!

 

read less
Comments

Btech,JEEQualified,Studied from ALLEN, Kota, deliver lectures on MATHS & SCIENCE for class 10th

Input:-a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples. Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list. Program: 1)...
read more

 Input:-a list of tuples with two values (order-number: string, total-order-cost: float) each Output:- the updated list of tuples.

Condition: When b < 100, b = b + 10 where b: total-order-cost (product of the price per items and the quantity) for every tuple of (a, b) in the input list. Program: 1) With regular for-loop: # You might use list(input()) to read list from user input. inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]   outputList = []   for _tuple in inputList: if (_tuple[1] < 100):      outputList.append((_tuple[0], _tuple[1]+10)) else:   outputList.append((_tuple[0],_tuple[1])) print('Updated List:',outputList)  

PS: Since tuples are immutable (cannot change it's value further) in python, we used one more list instead of replacing the given input list itself.

2) With list-comprehension:-  inputList = [('34587',163.8),('98762',284.0),('77226',98.85),('88112',74.97)]   def getUpdatedList(inputList):   return [(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList]   outputList = getUpdatedList(inputTuple) print(outputList)   Or simply,   print([(ele[0], ele[1]+10) if (ele[1]) < 100 else (ele[0], ele[1]) for ele in inputList])     

Feel free to ask me any further questions. enjoy coding.

read less
Comments

IT Professional Trainer with 10 years of experience in IT Industry

select orderid,productprice+10 from products where productprice<100
Comments

View 22 more Answers

Related Questions

Is it a good option to do a CA after a BTech? If yes, what is the procedure?
There are few factors you have consider: 1. Why do you have the idea of pursuing CA, is it out of your personal interest or something like as in recent days engineering is getting diluted and shortage...
Varsha
0 0
5
What is the average salary of BTech ECE freshers?
Average Salary for BTech would be 25k/month; in good company and lesser in small companies.
Satish
0 0
6
Will the JEE coaching fulfill the requirement for the class 12?
JEE coaching will definitely fulfill the class 12 requirement by addressing the nuances associated with every topic. The only thing to be borne in mind is that while analysing minute details for a particular...
Millennium
0 0
5
How to use recursive function in C?
Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the...
Pragati
How do I manage between school and coaching in class 12?
Time Management is key. Just you have to see that school and class time do not collide.
Pradeep
0 0
9

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons


Infix Expression To Post-fix Expression Conversion Procedure
Algorithm 1. Scan the infix expression from left to right. 2. If the scanned character is an operand, output it. 3. Else, a. If the precedence of the scanned operator is greater than the precedence...

SI Units
The name SI is abbreviation for Système International d’Unités for the International System of units. The 14th General Conference on Weights and Measures held in 1971, adopted seven...

DBMS
2Phase Lock in Distributed Database: In this protocol, it is required that all the data items must be reached in a mutually independent manner, i.e. when one transaction is performing, then no other transaction...

Engineering Drawing Preparation
Engineering Drawing preparation becomes easy if you follow the following steps. 1. Learn basic rules of Engineering drwaing like dimensioning, drawing different types of lines, construction of polygons...

Recommended Articles

MBA, Medicine and engineering are the three main professional courses in India. Engineering is still one of the highly sorted after professional courses in the under graduate level, while MBA is favoured as a preferred post graduate course. To shine in these courses, one needs to work and study hard. Engineering as a...

Read full article >

According to a recent survey conducted by the NCAER (National Council of Advanced Economic Research), engineering is the most sought after course in India. Some engineering courses are offered as BE or Bachelor of Engineering while some as Bachelor in Technology or B.Tech. Since engineering is a professional course, the...

Read full article >

Quality education does not only help children to get a successful career and life, but it also hugely contributes to society. The formal education of every child starts from school. Although there are numerous schools, parents find it challenging to choose the right one that would fit their child. It is difficult for them...

Read full article >

E-learning is not just about delivering lessons online. It has a much broader scope that goes beyond manual paper or PowerPoint Presentations. To understand the reach of E-learning and how the whole process works in developing the Educational system, we will discuss a few points here. Let us find out how this new learning...

Read full article >

Looking for BTech Tuition ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more