Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helloworld py file #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
24 changes: 24 additions & 0 deletions hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
import socket


def hello_world() -> str:
"""
Function that builds a message string, which introduces
the PC (hostname) and its python version to the world.
If python version is less than 3.6, the message indicates
that f strings can't be used and is sad (since f strings were
introduced at 3.6).

@Returns (str): built message
"""
message = "Hello world!"
if sys.version_info.major >= 3 and sys.version_info.minor >= 6:
message += f"\n\nI'm {socket.gethostname()} using python {sys.version_info.major}.{sys.version_info.minor} :)"
else:
message += "\n\nI'm {socket.gethostname()} using a python version older than 3.6 so I can't use f strings. :-("
return message


if __name__=="__main__":
print(message)