This question already has answers here:
Can you add new statements to Python's syntax?
(13 answers)
Add new statements to Python without customizing the compiler
(2 answers)
Closed 4 years ago.
Can I create a statement in python 2.7?
Something similar to the print statement, that it's like a function, but gets the parameters without parenthesis.
Related
This question already has answers here:
Why doesn't Python print return values?
(3 answers)
Function in Python not producing output? [duplicate]
(4 answers)
What is the purpose of the return statement? How is it different from printing?
(15 answers)
Closed 2 months ago.
def plus_ten(a):
return a + 10
plus_ten(2)
I thought that the plus_ten(2) would generate an output of 12, but when I run the code, it comes up with nothing.
Why is this?
This was lifted directly from: https://www.youtube.com/watch?v=lA9OuhldJd0&ab_channel=365DataScience
It shows in the video that there should be an output. However, in my VS studio, there is no output... please help!
This question already has answers here:
What algorithm does Python's built-in sort() method use?
(2 answers)
What is `lambda` in Python code? How does it work with `key` arguments to `sorted`, `sum` etc.?
(4 answers)
Understanding the map function
(6 answers)
Closed 1 year ago.
I found the following line of code which I'm unable to google as it has a custom function. Can someone please explain this?
list.sort(key=lambda v: map(int, v.split('.')))
I know this sorts a list but I want to understand which sort is it and how it works.
This question already has answers here:
How do I create variable variables?
(17 answers)
eval(): can't assign to function call
(1 answer)
Closed 2 years ago.
for N_RECORDS in ['50k','50m','100m','200m','python']:
eval("res_"+N_RECORDS) = spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_pos.csv")
eval("res_"+N_RECORDS+"_neg")=spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_neg.csv")
I just want to create objects with the names res_50k, res_50m, res_100m, res_50k_neg, etc without doing it manually.
However, I keep getting an error
SyntaxError: can't assign to function call
File "<command-1997330779535506>", line 2
eval("res_"+N_RECORDS) = spark.read.load("/tmp/xgb-rts/xgb_results_"+N_RECORDS+"_pos.csv"
How do I work around this?
This question already has answers here:
Python list sort in descending order
(6 answers)
Closed 5 years ago.
This is my code:
#这是一个有关旅行的程序
place=['北京天安门','西安兵马俑','香港游乐园','日本秋叶原']
print(place)
print(sorted(place))
print(place)
place.sorted(reverse=true)
print(place)
When I run my code, something Wrong happens.
place.sorted(reverse=true)
or
sorted(place)
Using the 2nd way, how can I give (reverse=true)?
Just use sorted(place, reverse=True).
This question already has answers here:
Asterisk in function call [duplicate]
(3 answers)
What does the asterisk do in Python other than multiplication and exponentiation? [duplicate]
(2 answers)
Closed 6 years ago.
Very Quick Question. I have a print function that looks like the statement below:
print(*Runner(x,y))
What is the * for in this case? I have no clue what it does in this context.