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) ]

Learn BTech Tuition +3 Python Python Anaconda Python Advanced

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.

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)

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",...

public class DemoApplication {

public static void main(String[] args) {

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

List<Order> list=new ArrayList();

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 + "]";

}

}

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)

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)

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...

Hello Anurag,

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!!!

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...

Hello Anurag,

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!!!

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,...

Hello Anurag,

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!!!

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,...

Hello Anurag,

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!!!

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)...

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.

IT Professional Trainer with 10 years of experience in IT Industry

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

Related Questions

I'm 2017 pass out  graduate looking for Data Structure & Algorithm training for coding interview preparation to get into product based companies within six months.Anyone from product based companies could mentor for preparation or any online resources available for preparation?

Prerequisite: You should be an expert in any programming language at the conceptual and implementation level. Follow the following steps:Implement some advance level program in C using arrays. Practice...
Vivek
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
What is the better option for class 10, coaching class, self-study or private tuition?
If you are taking coaching classes you must need self-study. Even if you take private tuition you must need self - study. If you have self-study no need of coaching classes and tuitions >private tuitions...
Neelima
what is frequency division multiplexing
Frequency-division multiplexing (FDM) is a scheme in which numerous signals are combined for transmission on a single communications line or channel. Each signal is assigned a different frequency (subchannel) within the main channel.
Mohd

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

Related Lessons

Difference Between Short And Long Term Deflections (Limit State Of Serviceability)
Difference between Short- and Long-term Deflections: Short-term deflection means the immediate deflection after casting and application of partial or full service loads, while the long-term deflection...

How to Study and Learn Better: Tips to Students!
Find out where, when and how you learn best: By taking notes? Reading one book at a time? Through all-out effort? Study groups? Organise your time and the place to study according to that. Take breaks. Check...

SQL Server Row Count for all Tables in a Database
ProblemI am a database consultant and one of my tasks involves getting the row counts from all the tables in the source database and comparing it against the corresponding table row counts in the target...

Object - Oriented Programming
As we know already JAVA is object oriented language. Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which are data structures that contain data, in the form...

Binary and Complete Binary Tree
Binary Tree - In a binary tree, every node except leaf node contains almost two children. - if every internal node contains precisely two children, then it is called 2-array binary tree. - leaves = Internal...
Find B.E. Tuition near you

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