python by ammar
python by ammar
After installation
Python can be used through MS notepad and notepad++.
Better to use python in a single IDE.
IDE means integrated development environment.
E.g visual studio > for this you have to get into google and then select your
stable version of IDE and then start to incorporate
Type “cmd / cmp” and then command prompt will be open.
Type >python---version
Or if it doesn’t work means you didn’t have any python installed.
Install it from its site which is freely available, and the again open command
prompt.
Type > python – version or python
It will show in output “the version of python that you had in your pc”
Python can be used from its original app.
Type “python” in search bar and open the app.
Python is case sensitive so keep in consideration while typing the code.
NOTEPAD AND PYTHON (format of file)
Open notepad and write the code
E.g: print(“hello world”)
print (“python_with_maryam”)
4+5
Save the file with extension .py
Open cmd and Type exit() and get out of the first section
Then type this way
python (address of the folder with format .py extention)
python C:\Users\hp\Desktop\python_with_maryam\firsttry.py
we will get the output of the file attached. This way
hello world
python_with_maryam
4+5 will not be executed because we have not yet used the print (“”).
BASIC COMMONDS
Type
Dir <for listing all the folders>
Cd<to open the folder>
Cd Desktop <to get into the folder of the desktop>
To go back one directory we will use code cd..
Mkdir (name of the folder to be made)
Mkdir python_with_maryam_ali > you will be in the same cmd but in the
desktop you will get a folder
Type half of the folder name and then enter tab you will get the name of
the whole folder.
Cd. For Absolut folder
Cd Desktop\python_with_maryam> enter we will enter into the directory
Than type code . and than our visual studio will get open into it.
WORKING IN VISUAL CODE
Now our visual studio is running inside the given directory
After installing click the extension
And install the python
Now click into the files section > create new file> name of the file with no
space>python_with_maryam
Also mention the .py extension at the end of each file we made in the visual
code
Get into the new folder>select interprer> from the bottom line>and chose
the recommended one
COMMENTS
We will be using # to make the code as comment
PEMDAS
Parenthesis exponents multiplication division addition subtraction
Left to right run sequence M D & A S
VARIABLES
Rules to assign in variables
o The variable should contain letters, numbers, or underscores
o Do not start with numbers
o Spaces are not allowed
o Do not use the keywords used by python (break, mean, median,
average)
o Short and descriptive
o Case sensitive. (lover case, upper case, letters should be used)
X=5
Print(x) 5
Type(X) ---
Print(type(x)) int