Python
Last updated: 2024, Mon Jun 3rd at 13:48 CDT
Python is a high-level, general-purpose programming language, with good amount of code readability. The readability refers to the ease with which a human reader can comprehend the purpose, control flow, and operation of source code.
# genrates a number 1-20 10 times
import random
roll = 10
dice = 20
i = 0
def per():
result = []
die = random.randint(1,dice)
result.append(die)
return result
while i < roll:
i += 1
final = str(per())[1:-1]
print ("die:",final)
To Install: #
Preferred method
Most distros will have Python installed aby default. If you need to reinstall it or need a different version, your package manager is often the best choice.
sudo pacman -S python
sudo apt install python3
sudo dnf install python3
sudo zypper in python3
openSUSE prefers the actual version but should correct and output a message like:
python3' not found in package names. Trying capabilities. python311' providing 'python3' is already installed.
Essentials #
It is best to install Pipenv, so you can install dependencies and manage virtual environments. This is a Virtual Environment that sandboxes(keeps independent) your dependencies, to keep it for damaging the global installation.
Extras #
Instead of setting up Pipenv, you can use a program called pipx. Pipx install and run Python applications in isolated environments, it automates a lot of the setup or even run the program without installing it. For more information consult pipx’s official site.