[Solved] python calculator with two float numbers as parameters [closed]

[ad_1] Hope this code may help you def add(a,b): print(a+b) def subract(a,b): print(a-b) def multipy(a,b): print(a*b) def divide(a,b): print(a/b) ch=”y” while ch==”y” or ch==”Y”: x = float(input(“first number : “)) y = float(input(“second number: “)) print(“…..MENU…….\n 1.Add\n 2.Subtract\n 3.Multiply\n 4.Divide\n”) op=int(input(“Enter your choice : “)) if op==1: add(x,y) elif op==2: subract(x,y) elif op==3: multipy(x,y) elif … Read more

[Solved] how to print a string who contains variables, the string is contained is .json file? [closed]

[ad_1] I think you should develop more on your fundamentals, and try out your own code before asking a question here. I guess what you are trying to achieve can be done like this. import json with open(“example.json”, “r”) as f: json_content = json.load(f) message = json_content[“message”] variable = “var” print(message.format(variable=variable)) # prints # this … Read more

(Solved) How to read each line in an input text file and determine if each line is true or false?

[ad_1] Since idk how to format things in comments if thats a thing, heres what i have now. @achampion def readline(lines): if lines in strings: return True else: return False with open(‘output.txt’, ‘w+’) as output_file: with open(‘input.txt’, ‘r’) as input_file: for lines in input_file: if readline(lines) == True: output_file.write(‘True\n’) print(‘true’) else: output_file.write(‘False\n’) print(‘false’) 2 [ad_2] … Read more