Welcome back, fellow forummers! In this post, we will learn how to build a simple python script, and
what to use behind the scenes.
This is the provided video: (this video is directly tied to this post, and is property of Estrade)
1. Get a Python IDE 🖥️
To code python, you need an IDE (Integrated Development Environment). We reccommend using
pyCharm by JetBrains, as the community version is free, and includes many nice features.
🎫 Download pyCharm FREE (community) edition at: https://www.jetbrains.com/pycharm/download/
💰 Download pyCharm FULL (original) edition at: https://www.jetbrains.com/pycharm/buy/#personal
Once you have your pyCharm setup, create a new project. Here are some basic commands:
2. Some basic commands ⭐️
Display "HELLO WORLD" on the screen:
print("HELLO WORLD")
Declare and print a variable:
variableName = "HELLO MAN"
print(variableName)
Mathematics with integers:
integer = 1
integer = integer + 4
# Now, the variable "integer" will be equal to 5
integer = integer - 5
# Now, the variable "integer" will be equal to 0
integer = integer +10
integer2 = 5 * 2
integer = integer + integer2
# Now, the variable "integer" will be equal to 20
# and the variable "integer2" will be equal to 10
print("integer =")
print(str(integer))
# ^^^
# This code turns "integer" from a integer to a string
Collect and print user input:
variableName2 = input("Enter some text: ")
print(variableName2)
Setup custom commands (one time):
command = input("/")
if command == "hello":
print("command ran successfully")
ADVANCED: Setup custom commands (infinite times):
while True:
command = input("/")
if command == "hello":
print("command ran successfully")
explanation:
while True is called a "while loop". It loops commands under it indefinitely, which in this case helps
us prompt custom commands after they have been used, instead of having to restart the whole script.
This is the continuing to this post:
https://estradium.wixsite.com/forum/forum/general-discussion/how-to-python-part-1
4. Libraries 📚
Libraries give you more commands to use in your scripts.
How to import libraries:
# import a library:
import [LIBRARY NAME] as [NICKNAME]
# import a sub-library:
from [LIBRARY NAME] import [SUBLIBRARY NAME]
Popular and Useful libraries:
datetime - used to track date and time
time - used to track time specifically
random - used to create random choices
qrcode - used to encode/decode QR codes
ADVANCED: tkinter - used to create desktop applications
ADVANCED: tkinter messagebox (sub-library) - used to create info, warning, error
and question pop-ups
5. Create a project 🛫
Once you know this, you should be set on creating your first python script. Here are some ideas of what to do:
Reminder software (uses tkinter messagebox and datetime)
World Clock (uses datetime)
Notepad GUI (uses tkinter)
Tic-Tac-Toe
Calculator
Calendar (uses datetime)
Mad Libs
Hangman
there are many more ideas, but these are the easiest to make.
Want a more in depth tutorial? Check out YouTuber Bro Code's 12 hour tutorial!
THIS IS NOT OUR VIDEO!
Thank you for contributing to this post, and we hope to improve you python experience. 😉