notation

turn function add(1, 4) into (add, 1, 4)

turn function add(1, 4) into (add, 1, 4) Question: I have been experimenting with using functions to make a mini programming language, but can’t find out how to turn the function add(1, 4) into (add, 1, 4) So far I have this: mem = {} def inp(text): return(input(text)) def store(name, value): mem[str(name)] = value def …

Total answers: 1

How to double the strings in Python ex. "Hello" to "HHeelllloo"

How to double the strings in Python ex. "Hello" to "HHeelllloo" Question: how do I do this with sliced notation? ex. "Hello" to "HHeelloo" Asked By: Peter Stoyanov || Source Answers: You can use join function and for loop to an empty string. The letters will be double of all letters. s="Hello" "".join([x*2 for x …

Total answers: 8

What does this notation do for lists in Python: "someList[:]"?

What does this notation do for lists in Python: "someList[:]"? Question: I sometimes get across this way of printing or returning a list – someList[:]. I don’t see why people use it, as it returns the full list. Why not simply write someList, whithout the [:] part? Asked By: Petr S || Source Answers: To …

Total answers: 6

Convert Scientific Notation to Float

Convert Scientific Notation to Float Question: Encountered a problem whereby my JSON data gets printed as a scientific notation instead of a float. import urllib2 import json import sys url = ‘https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-quid’ json_obj = urllib2.urlopen(url) QUID_data = json.load(json_obj) QUID_MarketName_Trex = QUID_data[“result”][0][“MarketName”][4:9] QUID_Last_Trex = QUID_data[“result”][0][“Last”] QUID_High_Trex = QUID_data[“result”][0][“High”] QUID_Low_Trex = QUID_data[“result”][0][“Low”] QUID_Volume_Trex = QUID_data[“result”][0][“Volume”] QUID_BaseVolume_Trex = …

Total answers: 3

Scientific Notation precision normalizing

Scientific Notation precision normalizing Question: My goal is simply to convert a string such as “1.2” to scientific notation without adding additional precision. The problem is that I always end up with superfluous 0s at the end of my output. >>> input = “1.2” >>> print ‘{:e}’.format(float(input)) 1.200000e+00 I’m trying to figure out how to …

Total answers: 3