Specialization in Python (with flask towards Data Science)
Instructor Mr. Vimal Daga Sir || IIEC - RISE || Google Drive (screen shots) || Telegram (updates) || Discord (doubts)
Anaconda | windows | mac os | linux | other
Q/A: How to read data stored in RAM?
will be updated soon
Note: deadline 15th August
Things learnt
- how to make python to launch notepad/ chrome/ any particular site in chrome
import os
os.system("notepad")
os.system("start chrome")
os.system("start chrome youtube")
- how to make python to speak out the argument passed
pip install pyttsx3
import pyttsx3
pyttsx3.speak("Welcome world")
pyttsx3.speak("It's good to learn How to learn")
Things learnt
- Summary :
- Fundamentals of learning (how to understand things)
- exploring what all we can do with command prompt in windows
- New :
- Underhood function of accessing an elements in list
- Varibales(at a time can store only one element) has its limitation, so we moved to lists
- Limitation of list data type (can only do row operations but not col operations), so we moved to numpy array (can do both row and column operations)
- In order to use a package first we need to know about it well rather using for the solving the current situation
- whats those
>>>
in live programming, its called REPL (Read Evaluate Print Loop) | webiste
- Idea : Take few minutes to go through the core usage/ limitation/ documentation of every module in use
notepad test.py # by deafults it is saved with "test.py" .txt extension
notepad "test.py" # no extension
dir # to check it
# when we declare a list to hold multiple elements, access them using list_name[index_number], the underhood function is
list_name.__getitem__(index_number)
# when we import a module, if we wants to what all the functions it provides
dir(module_name)
# what about built-in functions of python, then try this
dir(__builtins__)
1. Session
Summary
- To find out the way to browse a ram. (Suppose when we intialize any variable x=5; in our program than it is taught to us that it gets stored in ram but now how one can proof that it is present in the ram.)
- About GUI(Graphical User Interface) and CLI(Command Line Interface)
- How to open applications using terminal (eg. Typing Firefox on the radhat and pressing enter will open the browser)
- speak-ng command(to speak what O/P it is giving), date cmd, cal command, which command
- Saw that the cookies that fb and google send to our systems are very critical and even if someone by any way copies them to his/her system can get a complete acess of our Google and Facebook accounts or and other accounts and will never be asked to enter any username password and no otp verification will be there and also a 3 level verification will not work
2. Session
Summary
- how to pause the command by using 'sleep'
- difference between 'ctrl+z' and 'ctrl+c'
- use of '&'
- use of echo and how we can use it in different ways
- how to install rethat linux
- how to recognize the correct IP address
Installation of Rhel:
- Download any virutal box (vmware | oracle)
Note: This links are for windows, if your using another os, kindly search for appropriate one. - Download the iso file rhel 8
- Install the virtual box and setup the configurations
Note: This installation is wrt oracle virtual box
- open and click
New
- we can observe a popup box named "Create Virtual Machine" fill the detials like
Name(any)
,Type(linux)
,Version(RedHat 64bit)
and clickNext
Memory size
preferred 1GB or more and clickNext
Hard disk
chooseCreate a virtual hard disk now
option and clickCreate
Hard disk file type
chooseVDI(VirtualBox Disk Image)
option and clickNext
Storage on physical hard disk
chooseDynamically allocated
option and clickNext
File location and size
preferred 10GB to 100GB and clickCreate
- now the hardware setup is done, you can observe it in the left window
- for software setup, right click and choose
settings
and can check the hardware configuration's, go forstorage
settings settings
>storage
>Controller IDE : empty
click onempty
find Attributes in side windowAttributes
>Optical Drive
choose the ISO file location and clickOk
, now both hardware and software got setuped- click on file created (is avaliable in left window with the name 'Name(any)') and click
start
- now you can see a black screen with few options (cursor won't work, use arrow keys) and choose
Install Red Hat Enterprise Linux 8.0.0
- wait until you see
WELCOME TO RED HAT ENTERPRISE LINUX 8.0.0
and choose the required language - now you're at
INSTALLATION SUMMARY
click onInstallation Destination
Automatic partitioning selected and clickDone
- select the
Network & Host Name
to connect to the network and clickDone
- select
Software Selection
and chooseWorkstation
option from the available one's and clickDone
- select
Time & Date
to change the time zone and clickDone
- now click
Begin Installation
it takes some time to install - now at
CONFIGURATION
to setup the password for thrroot
- Finally the installation is done!!
Issue: If you can't see RedHat 64bit, kindly follow these steps:
- restart (shutdown and start).
- enter the bios (press f12).
- advance settings / CPU configurations.
- find
Enable Virtualization
and enable it. - save the settings (press f10) and start the system.
Note: check the function keys for your device and use it (they may vary from device to device).
Note: Still any issues can raise a question at channel
while : ; do echo -n -e "`date +%T``sleep 1`\b\b\b\b\b\b\b\b" ; done &
3. Session
Summary
4. Session
Summary
Q/A: How to tell your OS to send a whatsapp message to a particular number using python code?
# solution will be updated soon
# solution will be updated soon
# solution will be updated soon
Q/A: How to tell your OS to send an email to a particular email-id using python code?
# solution will be updated soon
Summary
- In general function's are used to perform respective tasks,
speak()
is a function which is available in thepyttsx3
module. which is used to output the audio from the system.
import pyttsx3
pyttsx3.speak('output the audio')
# this snippet makes system to speak out 'output the audio', in general, it speaks what ever the argument is passed to the speak()
- n order to perform some tasks we need respective function to do it, all these function's might not be available in the default module, sometimes we need to import few packages/modules for an special tasks to be done, just like
pyttsx3
module.
pip list # this shows what all modules we have
# if the module isn't available then install it.
pip install pyttsx3 # pip install module-name
- IDE - Integrated Development Enviroment | In jupyter (python + r + julia) |
shift + enter
to run cell |alt + enter
to run the cell and create a new cell |clt + enter
to run the selected cells |esc + d
will delete the cell - To run the system commands we need to, we need to use operating system functions to communicate with os and make those commands get executed
import os
os.system('firefox')
# this snippet enables us to run firefox bowser using python code
-
In the Menu- Driven program , we trying build the human interactive program, which performs the tasks whcih ever the user asks. Currently we're building it We a first task to build the as good as interactive model as we can.
-
help() funtion provides us the complete detail of the commands which we wants to use/ which we are using
print()
command has an argumentend = '\n'
by default it is set to a new, we can modify it and can see the changes in theprint()
function behaviour. -
conditional if and else, the name itself speaks for it
if True: do some task
else: dont do the task
# this is naive explaination.
simple application
# importing required modules
import os # use to access the os programs
import pyttsx3 # use to make python speak out for us !pip install pyttsx3
# if the modules aren't available, install them
# code
pyttsx3.speak(" Welcome to my application (here are the services we provide) ")
print("\n Welcome to my application (here are the services we provide) \n 1. launch firefox \n 2. launch chrome \n 3. launch notepad \n 4. Media Player")
pyttsx3.speak("Option one launch firefox browser")
pyttsx3.speak("Option two launch chrome browser")
pyttsx3.speak("Option three launch notepad")
pyttsx3.speak("Option four launch media player")
pyttsx3.speak("Kindly")
pyttsx3.speak("enter your choice")
user_input = int(input("\n Enter your choice :"))
# note the commands might vary to device to device
if user_input == 1:
os.system("firefox")
elif user_input == 2:
os.system("start chrome")
elif user_input == 3:
os.system("notepad")
elif user_input == 4:
os.system("wmplayer")
else:
pyttsx3.speak("Oops, you might have entered invalid input")
print('Invalid input !!')
Q/A: How to reverse the string using the slicing operator?
will be updating soon
Summary
-
we have explored how to run the
juypter notebook
from command promt, also we have seen few shortcuts in it -
new shortcut
alt + enter
to run the cell and create new cell -
string datatype holds bunch of characters, each of them can be indexed similar as lists
-
slicing operator is either used in lists/ strings to slice the data
x = 'this is the summary for day4'
x[0] # prints t
x[0: 4] # prints this
# this slicing from 0th pos to (4-1)th pos
x[0:4: 1] # prints this
# here the step size is 1
x[0:: 3] # prints t s t s m r f d 4
# here the step size is 3
x[-1] # prints 4
# this is used to print the last element
x[::-1] # prints the string in reverse
-
here we got introduced with the
in
keyword of python, which will be a major advantage in developing the human interactive program -
this will be a part of human interactive program, where we provide a menu for the user to select the option and make them executed using the python program, which do them interacting with os
-
logical opertors either it returns
True
orFalse
based on the condition is evaulated -
while
loop is similar likeif
statment, it executes as long the condition is satisfied. If the intial condition doesnt satisfy it wont enter into the loop -
break
keyword is used to terminate the loop -
use the concepts we learnt till date, we can input human usable language and extract keywords from it to perform the task which user requested
-
every string is can be accessed similar as list
x = 'hello'
print(x[0]) # prints out h
# we can even apply slicing operation
# prints starting pos to (5-1)th pos
print(x[:5]) # prints out hello
# in steps
# print(x[0:2:step_size])
# it prints it with step size of 2
print(x[0:5:2]) # prints out hlo
# to print the last one
print(x[-1]) # prints o
shift + enter
to run the cellalt + enter
to run and create a new cell- to check whether a word/ character present in given strinf we can use
in
keyword
x = 'this is the example done in jupyter notebook'
print(x)
if 'jupyter' in x:
print('Hurray!! given statement has juypter in it')
else:
print('Sorry!!')
import os
x = 'can you launch the chrome browser'
print(x)
if 'chrome' in x:
os.system("start chrome")
else:
print('Sorry!!')