Gmail, one of the most popular email services in the world, supports millions of users, delivering robust performance, high availability, and strong security...
Introduction. Have you ever wondered how to build a scalable system like the one you use most for interview practice? Leetcode has become a cornerstone for s...
Introduction:. In today's mobile-first world, having a website that performs seamlessly on mobile devices is no longer optional—it's imperative. Mobile optim...
Create the Lazy-Loaded Component. In the application, add a new component using the Angular CLI command, as shown below.
Basic Introduction. Nodejs is a JavaScript runtime build over Chrome's V8 JavaScript engine. Nodejs is generally used a backend tool to cater to client apis.
At times we must have come across a situation wherein we had to scrap a website and process the data in some way, like. ,
def listsum(a,b): print("Sum: ",(a+b)) listsum(10,20)
public class code{ public static void main(String[] args) { int num1 = 10; int num2 = 20; System.out.println("Sum = "+(num1+num2)); } }
#Write a list of your favorite foods and ask the user their favorite foods print("Hey! My name is Ernesto, its nice to meet you; what's your name?") user_name = input() print("Nice to meet you", user_name) print("This is going to sound like a random question, but what are your favorite foods?") #user has two options to continue the converstation #choice 1 is: what for? #choice 2 is: Why do you care? user_options = (">what for \n>Why do you care?") print(user_options) print("please choose option 1 or 2") user_answer = input() if user_answer in {'1', 'one', 'One', 'Option one', 'option one', 'Option 1',}: print("It's for my python class!") if user_answer in {'2', 'Two', 'two', 'Option two', 'option two', 'Option 2', 'option 2'}: print("Ight, Nvm then"), quit() #after user chooses from the two options, continue with program #User inputs their favorite foods from a list of 5, #Me personally, my top 5 are: (Tostadas, Mole, Penne Vodka, steak, potatoes) print("Please enter your top 5 foods seperated by a comma:") user_answer2 = input() my_list = ["Tostadas", "Mole", "Penne Vodka", "Steak", "Potatoes"] user_list = [input(), input(), input(), input(), input()] if user_answer2 in {'Tostadas', 'Mole', 'Penne Vodka', 'Steak', 'Potatoes'}:
####################################################### # Apply each transaction to the customer's balance # Display the final dataframe with 2 columns [customer_id, new_balance] ############################################################# # customer_id , balance customers = [ (1, 250), (2, 80), (3, 120), (4, 77)] # customer_id, transaction, amount transactions = [ [ 1, 'credit',30], [ 1, 'debit', 25], [ 2, 'debit', 55], [ 3, 'credit',20], [ 3, 'debit',155], [ 1, 'credit',50], [ 2, 'debit', 80], [ 1, 'credit',60]] def apply_transaction(t,c): print("Apply_transaction arguments", t,c) for t_each in [t]: print("t_each =",t_each) c_balance = c[1] c_id = c[0] t_id = t_each[0] t_type = t_each[1] t_amt = t_each[2] new_bal = 0 if t_type == 'credit': new_bal = c_balance + t_amt elif t_type == 'debit': new_bal = c_balance - t_amt else: print("Erorr: different transaction") print("Old balance: ", c_balance) print("new balance", new_bal) return new_bal def calc_balance(t,c): l_cust = [cu[0] for cu in c] print("Unique customer", list(set(l_cust))) res_t = [] for c_unique in l_cust: for tra in t: print ("Transaction looking:", tra[0], tra[1],c_unique ) if (tra[0]==c_unique): print("Found one", c_unique, tra[1], tra[2]) res_t.append(tra) print("Unique customer",c_unique, " unique cust transaction", res_t) t_cust= [[ 1, 'credit',30], [ 1, 'debit', 25]], c_customer = (1,250) print("aqpplying function calc_balkance") upated_cust_trans = list(map (lambda a: apply_transaction(a,c_customer), t_cust)) print("Updated cust trans", upated_cust_trans) apply_transaction([ 1, 'debit',30],(1, 250)) apply_transaction([ 1, 'credit',30],(1, 250)) calc_balance([ [ 1, 'credit',30], [ 1, 'debit', 25], [ 2, 'debit', 55]], [ (1, 250), (2, 80)] )
####################################################### # Apply each transaction to the customer's balance # Display the final dataframe with 2 columns [customer_id, new_balance] ############################################################# # customer_id , balance customers = [ [1, 250], [2, 80], [3, 120], [4, 77]] # customer_id, transaction, amount transactions = [ [ 1, 'credit',30], [ 1, 'debit', 25], [ 2, 'debit', 55], [ 3, 'credit',20], [ 3, 'debit',155], [ 1, 'credit',50], [ 2, 'debit', 80], [ 1, 'credit',60]]
fav_foods = ['french toast', 'cinnamon rolls', 'spaghetti', 'mashed potatoes', 'oranges'] user_foods = [] print('I wonder if we like any similar foods!') user_foods.append(input('What is a food that you like?')) if fav_foods.count(user_foods[0]): print('Oh wow! I love that too!') else: user_foods.append(input('How about another food?')) if fav_foods.count(user_foods[1]): print('Oh wow! I love that too!') else: user_foods.append(input('One more?')) if fav_foods.count(user_foods[1]): print('Oh wow! I love that too!') else: print('Well, we certainly tried.')