Python: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* http://www.python.org
=Internal=
=Internal=
* [[Conda]]
* [[Conda]]
* [[pip]]
* [[pip]]
Line 7: Line 9:


=Subjects=
=Subjects=
* [[Python and IntelliJ IDEA#Overview|Python and IntelliJ IDEA]]
* [[Python and IntelliJ IDEA#Overview|Python and IntelliJ IDEA]]
 
* [[Python Installation]]
=Installation=
* [[Python Language]]
 
* [[Python Style Guide]]
==Mac==
 
<syntaxhighlight lang='bash'>
brew install python3
</syntaxhighlight>
 
==Linux==
<syntaxhighlight lang='bash'>
yum install python3
</syntaxhighlight>


=Organizatorium=
=Organizatorium=
Line 30: Line 21:
** ~/Library/ApplicationSupport/iTerm2/iterm2env/versions/*/bin/python3
** ~/Library/ApplicationSupport/iTerm2/iterm2env/versions/*/bin/python3
** ~/Library/ApplicationSupport/iTerm2/Scripts/YourScript/iterm2env/versions/*/bin/python3
** ~/Library/ApplicationSupport/iTerm2/Scripts/YourScript/iterm2env/versions/*/bin/python3
=Basic Language=
Printing done with print() function.
<syntaxhighlight lang='py'>
print('something')
</syntaxhighlight>
Comments:
<syntaxhighlight lang='py'>
# This is a comment
</syntaxhighlight>
Variables.
<syntaxhighlight lang='py'>
a = 1
b = 'something'
print(a)
print(b)
</syntaxhighlight>
Functions:
<syntaxhighlight lang='py'>
def function_name(arguments):
  <function body>
def something(a, b):
  c = a + b
  return c
</syntaxhighlight>
Conditions:
<syntaxhighlight lang='py'>
if a == 1:
  print('something')
else:
  print('something else')
</syntaxhighlight>
Loops:
<syntaxhighlight lang='py'>
while <condition>:
  code-block
while x < 5:
  x = x + 1
  print
</syntaxhighlight>
String functions:
* Concatenate strings: <code>'a' + 'b'</code>
* Concatenate strings and integers: <code>'a' + str(1)</code>
<font color=darkgray>TODO. Continue: https://levelup.gitconnected.com/python-for-absolute-beginners-a-quick-primer-c7db94a5d0e</font>

Revision as of 05:57, 26 May 2021

External

Internal

Subjects

Organizatorium

  • https://opensource.com/article/18/1/running-python-application-kubernetes
  • Each installation of Python may have different modules installed. Python determines the path to its modules by examining the location of the python3 executable.
  • Python environments on Mac:
    • ~/Library/ApplicationSupport/iTerm2/iterm2env/versions/*/bin/python3
    • ~/Library/ApplicationSupport/iTerm2/Scripts/YourScript/iterm2env/versions/*/bin/python3