Why is there no output in this function/parameter? [duplicate] - python

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!

Related

I'm trying to append to a list in python but it gives back a NoneType [duplicate]

This question already has answers here:
Why does "x = x.append(...)" not work in a for loop?
(8 answers)
Closed 2 years ago.
This is my code but my output gives a none type back and not a list full of numbers.
PHC=[]
for i in range(len(df)):
x=df['HC'][0:i+1].mean()
PHC=PHC.append(x)
len[df]['HC']
instead of
len[df]

What is meaning of '#' operator? [duplicate]

This question already has answers here:
What is the '#=' symbol for in Python?
(3 answers)
What does the "at" (#) symbol do in Python?
(14 answers)
Closed 3 years ago.
I have come across this code and I have seen this unusual operation:
return Xtrain # eigenvectors[:2]
Does anyone know what it does?
Python documentation says:
Matrix Multiplication
Operator
a # b
Function
matmul(a, b)

Is it possible to create a statement in python? [duplicate]

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.

Python :error'list' object has no attribute 'sorted' [duplicate]

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

Asterisk in Python 3 print function. What is it for? [duplicate]

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.

Categories