Michele Sessa
1984891870
|
2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago |
README.md
Hello Python
Here starts your journey in the marvelous world of Python, a very versatile programming language, popular for being accessible for beginner programmers and yet very powerful.
Setup
First, you'll need to have Python installed on your machine. In those exercises we use Python 3.10, we then recommend you to install Python 3.10 or higher.
To write your code, you may use your favorite IDE. If you don't have one, you can go for Visual Studio Code with Python extension pack installed:
- Get VS Code
- (Optional) The Python extension pack.
Setup may vary in base of your Operating System or machine specificities, if you feel stuck check on internet for the specific steps that suits your configuration.
Instructions
Create a file hello_python.py
and write inside a function say_hello_python
that returns the string "Hello Python!"
.
def say_hello_python():
# this is a function,
# write your code here
Usage
Here is a possible code to test your function. Put it in another file (ex: test.py
):
from hello_python import say_hello_python
print(say_hello_python())
Run your test file with the following command:
$ python3 test.py
Hello Python!
$
test.py
file should be in the same directory ofhello_python.py
in order to work.
Hints
-
Python uses indentation to indicate in which block your code will run (many other languages uses parenthesis instead). It is then very important to indent your code properly.
-
return
is a special world used to say which value a function should return (a function could also not return anything). For examplereturn 10
will return the number ten. -
A string is a set of characters wrapped by
"
. For example"Ciao bella"
is a string containing the worldsCiao Bella
. -
In
test.py
we are calling another function namedprint
. This function is already present in Python standard library so we don't have to create it. This function at its core is made to write strings in the standard output.