Posts

Showing posts from October, 2019

DAY 8 - Image To Text And Image To Audio Using Python Script

Image
DAY 8 - Image To Text And Image To Audio Using Python Script 1. open a python file from desktop and execute it in python IDLE. That's way, next file will be picked from Desktop by default. That's my personal experience. Please do this step as a prerequisite 2.  Install these libraries using below commands.     Open command prompt and move to path "C:\Users\Rakesh.Ranjan\AppData\Local\Programs\Python\Python37-32\Scripts>" and then execute below commands       >>> pip install pytesseract ## will convert the image to text string     >>> pip install googletrans ## google translator library     >>> pip install gTTS        ##Text To Audio 3. # import the following libraries # will convert the image to text string import pytesseract      # adds image processing capabilities from PIL import Image #translates into the mentioned language from googletrans imp...

DAY 7 - Text To Audio And Audio To Text Using Python Script

 Text To Audio And Audio To Text Using Python Script #Text To Audio using Python Script ############################################## 1. Install gTTS using below command: Open command prompt and move to path "C:\Users\Rakesh.Ranjan\AppData\Local\Programs\Python\Python37-32\Scripts>" and then execute below command to install gTTS pip install gTTS 2. >>> import sys    Using the command to know path variables    >>> sys.path    Audio file will be saved at one of these paths 3. #module for text to speech conversion from gtts import gTTS mytext = 'Welcome to India, Mr Mike !' #command to convert text to audio myobj = gTTS(text=mytext, lang=language, slow=False) #saving the file in mp3 format myobj.save("WelcomeFile.mp3") 4. Steps to find the file location import os.path from os import path >>> path.exists("WelcomeFile.mp3") True >>> path.realpath("WelcomeFile.mp3") ...

DAY 6 - Function ,lambda ,module ,Iterator ,map ,filter ,reduce ,List Comprehension ,Exception Handling ,*args ,**kwargs

#Function #lambda #module #Iterator #map #filter #reduce #ListComprehension #ExceptionHandling #*args #**kwargs 1. Function :    A function is a reusable block of programming statements designed to perform a certain task.   def function_name(parameters):     statement-n     return [expr]     for example, def Myself(name, age, gender):     if gender == 'M':        print ("Hey Man.Who are you ? ")        print ("Hi! My name is {} and I am {} years old".format(name,age))     else:        print ("Hey Ma'am.Who are you ? ")        print ("Hi! My name is {} and I am {} years old".format(name,age))     return >>> Myself('Rakesh',30,'M') o/p: Hey Man.Who are you ? Hi! My name is Rakesh and I am 30 years old # Recursive Function : Recursive function involves successively calling it by decrementing the number...

DAY 5 - Decision Control & Loop

#DecisionControl #Loop #Command for user input: name = input("Enter your name: ") #Decision Control ########################################## 1. if [boolean expression]:     [statements] 2.  if [boolean expression]:     [statements] else:     [statements] 3. if [boolean expression]:     [statements] elif [boolean expresion]:     [statements] elif [boolean expresion]:     [statements] elif [boolean expresion]:     [statements] else:     [statements] #Loop ########################################## 1. #While Loop  while [boolean expression]:         [statements] for example: num =0 while num< 5:     num = num + 1     print("num =", num) o/p: num = 1 num = 2 num = 3 num = 4 num = 5 2. #For Loop #The for loop is used with sequence types such as list, tuple and set.The body of the for loop is executed for each...

DAY 4 - Data Types

#PythonDataTypes #list [] tuple () dictionary {key:value} set {} #immutable objects -  Number values, strings and tuple #mutable objects - list and dictionary These are built-in data types in Python: 1. Numeric    a. Integer - # type(7)  <class 'int'>    b. Float - a real number with a fractional component  #type(7.0) <class 'float'>    c. Complex Number - a + bj where a and b are floats and j is -1(square root of -1 called an imaginary number) #type(5+6j) <class 'complex'>      Conversion:    > int(7.5)      7    > float(7)      7.0    > complex(7.5) (7.5+0j)    > float(5+6j)  TypeError: can't convert complex to float      Operations:    + (Addition),- (Subtraction),* (Multiplication),/ (Division),% (Modulus),** (Exponent),// (Floor Division)      Built-In Fun...

DAY 3 - Strings

# PythonStrings hashtag # Python doesn't support character type. so a single letter will be treated as a string of length - 1 and index starts from 0. val ="He is a good guy." val1 = 'She is a good gal.' > val[-1] # '.' > val1[1] #'h' > val1[1:] # 'he is a good gal.' > val[1:4] # 'e i' > number = '123456789' > even_number = number [1: :2] # '2468' hashtag # pick every alternate digit from index = 1 > odd_number = number [0: :2] # '13579' hashtag # pick every alternate digit from index = 0 > Sibling = 'RAKESH_RUPESH_RITESH_PUJA' > first_Sibling,second_Sibling,third_Sibling,fourth_Sibling = Sibling.split('_') # 'RAKESH' 'RUPESH' 'RITESH' 'PUJA' > 'PUJA' in Sibling hashtag # True > first_Sibling * 2 # 'RAKESHRAKESH' # multiply sequence by integer only > first_Sibling + second_Sibling # 'RAKE...

DAY 3 - Operators

a = 10 # 1010 b = 20 #0001 0100 c = 0 1. Bit-wise Operator: c = a & b; # 0 = 0 # Operator copies a bit to the result if it exists in both operands c = a | b; # 30 = 0001 1110 # It copies a bit if it exists in either operand. c = a ^ b; # 30 = 0001 1110 # (a XOR b) c = ~a; # 5 = 0101 # It is unary and has the effect of 'flipping' bits. c = a << 2; # 40 = 0010 1000 # The left operands value is moved left by the number of bits specified by the right operand. c = a >> 2; # 2 = 0000 0010 # The left operands value is moved right by the number of bits specified by the right operand. 2. Comparison Operator: It returns Boolean value i.e. either True or False > a == b hashtag # False > a != b hashtag # True > a < b hashtag # True > a > b hashtag # False > a <= b hashtag # True > a >= b hashtag # False 3. Logical Operator: Logical operators...