1

Use of Python in Chemistry

Description

The program has a choice of two methods to calculate volume of a molecule: Van der Waals volume and the ideal gas law.

IMPORTANT: For this to work, an empty excel csv file named perfectGas needs to be saved in the same place as the file for the code is saved in.

If choice 1 is entered, the volume is calculated by Wan der Waals formula and if 2 is entered, the volume is calculated by PV=nRT

1) Option 1 calculates the volume with Van der Waals volume formula

The user must enter the formula of molecule which are in the elements list, followed by the number of aromatic and non-aromatic rings.
An example calculation of benzene is given below

Input instructions for Wan der Waals and output against the input values:

””’Enter the choice : 1
Please enter the formula of molecule : C6H6
Enter the number of non-aromatic rings in the molecule : 0
Enter the number of aromatic rings in the molecule : 1

Output:
Occurrence of molecule in elements list : [‘C’, 6, ‘H’, 6]
Van der Waals volume is: 81.17 ų (Å3 it is taken as unit ) ””””

2) Option 2 uses the ideal gas law (pV = nRT) to calculate volume of a molecule or other parameters if the user chooses

The user can press p, V, n or T to calculate any parameters and the values are saved in a csv file.

The code can accept these parameters in non-standard units such as atmospheres and degrees Celsius.

Input Instructions for PV=nRT and output against the input values:

”””Enter the choice : 2
What do you want to calculate? (entry is case sensitive): For pressure press ‘p’ , for volume press ‘V’ , for moles press ‘n’ and for temperature press ‘T’ : V

Enter the temperature in °C : 25
Enter the Pressure in atm : 1
Enter the number of Moles : 0.05

Output:

Pressure: 1.0 atm Calculated Volume : 0.0012232021218850234 m³ Moles: 0.05 Temperature: 25.0 °C

IMPORTANT : Again, to reiterate, for this to work an empty excel csv file named perfectGas needs to be saved in the same place as the file for the code is saved in.

Mostly all functions are called in exec function which is in the last of the code .

Comments are included in the code for easier code reading

CODE


#open and save a blank excel file called perfectGas.csv in same place as this code as per ReadMe.txt file
import matplotlib.pyplot as plt
# matplotlib library for graph plotting
import re
# re library for regex
import math
# math library for math functions
import string
elements ={"H": 1.20, "He": 1.40, "Li": 1.82, "Be": 1.53,
"B": 1.92, "C": 1.70, "N": 1.55, "O": 1.52, "F": 1.47,
"Ne": 1.54, "Na": 2.27, "Mg": 1.73, "Al": 1.84,
"Si": 2.10, "P": 1.80, "S": 1.80, "Cl": 1.75,
"Ar": 1.88, "K": 2.75, "Ca": 2.31, "Sc": 2.30,
"Ti": 2.15, "V": 2.05, "Cr": 2.00, "Mn": 1.97,
"Fe": 1.94, "Co": 2.00, "Ni":1.63, "Cu":1.40,
"Zn": 1.39, "Ga": 1.87, "Ge":2.11, "As":1.85,
"Se": 1.90, "Br": 1.85, "Kr": 2.02, "Rb": 3.03,
"Sr": 2.49, "Y": 2.40, "Zr": 1.86, "Nb": 2.07,
"Mo": 2.09, "Tc": 2.05, "Ru": 2.05, "Rh": 2.00,
"Pd": 1.63, "Ag": 1.72, "Cd": 1.58, "In": 1.93,
"Sn": 2.17, "Sb": 2.06, "Te": 2.06, "I": 1.98,
"Xe": 2.16, "Cs": 3.43, "Ba": 2.68, "La": 2.40,
}
#atomic radii of elements
# user can choose to calculate volume with either the ideal gas equation, or the Van der Waals volume equation
print ("Hello, what formula do you want to use to calculate the volume of your molecule?")
print("----Press 1 for Van der Waals solution------- ")
print("----Press 2 for ideal gas law solution----- ")
choice=int(input("Enter the choice : "))

if(choice==1):
no_of_bonds = 0
volume = 0
x = 0
tempvol = 0
found = False
while found == False:
found = True
# inputs for Wan der Waals solution
# Enter the formula from the elements in the above list
molecule = input("Please enter the formula of molecule : ")
# regex include for proper format to find molecule in element list
list_of_molecule = re.findall('[A-Z][a-z]?|[0-9]+', molecule)
non_aromatic_rings = int(input("Enter the number of non aromatic rings in the molecule : "))
aromatic_rings = int(input("Enter the number of aromatic rings in the molecule : "))
moleculelist_maxlenth = 2 * len(list_of_molecule)
for i in range(0, moleculelist_maxlenth):
try:
if (list_of_molecule[i] in elements) and (list_of_molecule[i + 1] in elements):
list_of_molecule.insert(i + 1, "1")
except IndexError:
break

if (list_of_molecule[-1] in elements):
list_of_molecule.append("1")

for i in range(0, len(list_of_molecule)):
if list_of_molecule[i].isdigit():
list_of_molecule[i] = int(list_of_molecule[i])
# Occurrence of molecule in elements list
print(" ")
print("Occurrence of molecule in elements list :" ,list_of_molecule)
for a in range(0, len(list_of_molecule)):
if (list_of_molecule[a] in elements):
tempvol = ((4 / 3) * math.pi * pow((elements[list_of_molecule[a]]), 3))
volume = volume + tempvol
else:
volume = volume - tempvol
tempvol = tempvol * (int(list_of_molecule[a]))
volume = volume + tempvol
no_of_bonds = no_of_bonds + list_of_molecule[a]
# bonds calculation by number of aromatic rings and non aromatic rings
no_of_bonds = no_of_bonds - 1 + aromatic_rings + non_aromatic_rings
volume = volume - (5.92 * no_of_bonds) - (14.7 * aromatic_rings) - (3.8 * non_aromatic_rings)
print("Van der Waals volume is:",round(abs(volume) , 2), "Å\u00b3")

# Angstroms cubed, Å3 is the unit

elif(choice==2):
r1 = 298.15
# inputs of either temperature ,pressure ,number of moles, or volume and the other parameters will be asked for
what = str(input("What do you want to calculate? (entry is case sensitive): For pressure press 'p' , for volume press 'V' , for moles press 'n' and for temperature press 'T' : "))
if(what=='p'):
t1 = float(input("Enter the temperature in °C : "))
pressure=None
V = float(input("Enter the volume in m\u00b3 :"))
n = float(input("Enter the number of moles :"))
elif(what=='V'):
t1 = float(input("Enter the temperature in °C : "))
pressure = float((input("Enter the pressure in atm : ")))
V=None
n = float(input("Enter the number of moles :"))

elif(what=='T'):
pressure = float((input("Enter the pressure in atm : ")))
V = float(input("Enter the volume in m\u00b3 :"))
n = float(input("Enter the number of moles :"))
t1=None
elif(what=='n'):
t1 = float(input("Enter the temperature in °C : "))
pressure = float((input("Enter the pressure in atm : ")))
n=None
V = float(input("Enter the volume in m\u00b3 :"))
else:
print("Invalid Choice")

#the user can choose to calculate pressure, temperature, moles or volume
# t1 = float(input("Enter the temperature °C : "))
# pressure = float((input("Enter the Pressure in atm : ")))
# V=float(input("Enter the volume in meters cubed :"))
# n=float(input("Enter the numbers of Moles :"))
R = 0
S = 0



'''
parameters as input: data(list of values calculated in perfectgGas function), filename
This function is used to save the data calculated and readings in csv format
Csv files are made by using pandas library

'''
def perfectGasCSV(data, filename="perfectGas.csv"):
import pandas as pd
output = pd.DataFrame()
output = output.append(data, ignore_index=True)
output.to_csv(filename, index=False, mode='a', header=False)


'''
The ideal gas solution takes three parameters from the user and calculates the missing one, it also
calls the above function perfectGasCSV to save data points in csv file.
'''

def perfectgas(what, p, V, n, T):

if what is None:
return

R = 8.314
data = []

# if p is selected, pressure is calculated
if (what == "p"):
p = (((n) * R * (T+ 273.15 ) / (V))/ 101325)

data = {"p": p, "V": V, "n": n, "T": T}
perfectGasCSV(data)
result = "The Calculated Pressure : {0} atm Volume: {1} m\u00b3 Moles: {2} Temperature: {3} °C".format(p, V, n, T)
print(" ")
print(result)
return p
# if V is selected, volume is calculated
elif (what == "V"):
V = (n) * R * (T + 273.15) / (p * 101325)

data = {"p": p, "V": V, "n": n, "T": T}
perfectGasCSV(data)
result = "Pressure: {0} atm Calculated Volume : {1} m\u00b3 Moles: {2} Temperature: {3} °C".format(p, V, n, T) # data
print(" ")
print(result)
return V
# if n is selected, number of moles is calculated
elif (what == "n"):

n = ((p * 101325 ) * (V)) / (R * (T + 273.15))

data = {"p": p, "V": V, "n": n, "T": T}
perfectGasCSV(data)
result = "Pressure: {0} atm Volume: {1} m\u00b3 Calculated Moles: {2} Temperature: {3} °C".format(p, V, n, T)
print(" ")
print(result)
return n
# if T is selected, temperature is calculated
elif (what == "T"):

T = ((((p * 101325) * (V)) / ((n) * R))-273.15)

data = {"p": p, "V": V, "n": n, "T": T}
perfectGasCSV(data)
result = "Pressure: {0} atm Volume: {1} m\u00b3 Moles: {2} Calculated Temperature : {3} °C".format(p, V, n, T)
print(" ")
print(result)
return T

else:

return "Incorrect Input"


#unknown is calculated


def exec(what, pressure, V, n, t1, R, S):


if (what and R and S):
x_lab = ""
y_lab = ""
data_x = []
data_y = []
y=range(R,S)
for i in y:
# if the pressure is calculated, it is then appended in data list
if what == 'p':
data_x.append(i)
data_y.append(perfectgas(what, None, i, n, t1))

# if the volume is calculated, it is then appended in data list
elif what == 'V':
data_x.append(i)
data_y.append(perfectgas(what, i, None, n, t1))

# if the temperature is calculated, it is then appended in data list
elif (what == 'T'):
data_x.append(i)
data_y.append(perfectgas(what, pressure, i, n, None))



else:

perfectgas(what, pressure, V, n, t1)

# calling of the main function exec for all possible operations, all functions of code are called inside this function
exec(what,pressure,V,n,t1, R, S)


else:
print("Invalid Choice .Please Press 1 or 2 for operations")


0

how to make first letter capital in python?

We use string capitalize() in Python to make the first character of the string capital while making all other characters in the string lowercase letters

Syntax: 

string_name.capitalize() 

string_name: It is the name of string of
             whose first character we want
             to capitalize

Parameter: The capitalize() function in python doesn’t take any parameter
Return value: The capitalize() function returns a string with the first character in the capital. 
Below is an Example of the use of capitalize() function in python:  

Python Program showing use of capitalize()

#testing string 
name = "shAad Coding"



print(name.capitalize())

#applying capitalize() funcion on different words individually
print("sHAAD".capitalize())
print("codIng".capitalize())

OUTPUT

Shaad coding
Shaad
Coding

keep visiting : shaadcoding

0

Secret Tips and Tricks to Rank your Gig on Fiverr First Page 2021

Rank your gig on fiverr first page 2021

Rank your Gig on Fiverr First Page 2021 – Fiverr is the best freelance marketplace/platform for beginners as well as for experts. Some extra features of this freelance platform provide amazing opportunities for beginners to earn and grow earning up to six-figure income yearly.

You can offer services to customers worldwide easily but unfortunately, to start earning and get orders, you must have to rank your gigs on the first page.

And obviously, you are here for that, how to rank gigs on Fiverr first Page 2021. Here I come with 7 Tips and Tricks to Rank your Gig on Fiverr first Page 2021.

First we need to know that How Fiverr’s Search Algorithm Works 2021.

  1. Proper Onpage and Offpage SEO.
  2. Response Time
  3. Order Completion Rate
  4. Positive Rating
  5. Conversion Rate
  6. Online Status of Profile (70% to 80% Ranking depend on this 100% verified)

Let’s start how we can Rank our Gig on Fiverr first Page.

1.1 Proper Onpage SEO:

The first thing which we need to do is on-page SEO. In on-page SEO we need to work on 4 things.

  1. Main Keyword in Gig Title
  2. Main Keyword in Gig Description
  3. Proper Related Keywords in Tags Field
  4. Put the main keyword and related keywords in Image details (Pro Tip)

Main Keyword:

After proper keyword research and finding one main keyword. You need to put the keyword in the keyword title.

For example, our main keyword is “fashion luxury logo” then,

Main keyword in title will be like.

Rank your Gig on Fiverr First Page 2021

After that, you must put your main keyword in Gig Description at least 3 times. At the start of the description, after the first paragraph, and then in the last the summary paragraph.

Now one more thing you need to do is put keywords in tags, there we can put a maximum of 5 keywords. So ensure that you put the main keyword in the middle position (3rd place). For example like that.

Rank your Gig on Fiverr First Page 2021
Rank your Gig on Fiverr First Page 2021

Now time for a Pro Tip:

Firstly the images you placing in your gig thumbnail must be Eye-catching. Now we need to put the main keywords in Image Properties.

Right-click on the image (one by one) and then click on “Properties“. Now click on the “Details” tab, and put all the keywords, as shown in the image. The blue dots details must be fulfilled.

Rank your Gig on Fiverr First Page 2021
Rank your Gig on Fiverr First Page 2021

1.2. Proper Offpage SEO:

For Offpage SEO, we just need to share our Gig Url on different social media platforms that we generally use. E.g. Facebook freelance pages, Whatsapp groups.

We can also make a Portfolio website for our services and connect with the Fiverr website.

2. Response Time:

Try to keep a good and sudden response time. This will help you in Ranking as well as more Conversion Rate. Response Time is the time that you respond to the first message of a new client.

The best way to keep good response time is, install Fiverr Mobile App.

3. Order Completion Rate

The order completion rate also affects the gig ranking. As you know the Fiverr Level system, Order Completion Rate, Response Rate, On-time Delivery, and Rating must be 90% and above.

So you can get idea how important that will be for Gig Ranking.

4. Positive Rating:

A positive rating directly impacts your gig ranking. As Fiverr browse best sellers for their buyers for the best experience of the buyer. Fiverr will never show your gig on the top first page if your rating is low.

Rank your Gig on Fiverr First Page 2021
Rank your Gig on Fiverr First Page 2021

5. Online Status of Profile:

Last but a Pro Tip for you, keep your profile online as much as you can. I heard this on Fiverr Forum from experts and then I implement this.

I am 100% sure that, if your profile status is online for a minimum of 16hours daily, I guaranty your gig will rank on the first page.

Also, keep in mind that if your profile status is online then you will get messages from buyers, So you must keep your eye on Conversion Rate. It depends on you to Respond faster than before someone entertains that buyer.

One more thing buyers come on Fiverr for orders at a specific time. so you need to note the time of your niche-related buyers.

Get your first order faster, so it will help you to rank and become a rated seller. You can also get a first fake review from your friend and family, but ensure you read the policies of Fiverr.

Thanks for reading. Hope you like the article, for the appreciation you can make a Fiverr account through our Referral Link. Like Comment and Share with your friends.

keep visiting : shaadcoding
0

Top Programming Languages In 2021 [Best 10]

Top Programming Languages In 2021

Top Programming Languages In 2021 – The growing demand in IT industry can make it confusing to pick one programming language that is suitable and helpful for an individual. So in this article, we will walk you through the top 10 programming languages for the year 2021. We have analyzed and understood the high-demand coding languages in the coming year this list can help you plan your career in 2021.

Top Programming Languages In 2021, let’s start

10. C#

c# is an object-oriented and easy-to-learn programming language. It is fast and supports a large number of libraries for rich functionality and this makes it the next best choice after c++.C# programming language is popularly known for developing windows and its applications. And now it is also being used for developing windows and even VR games. The companies using c-sharp as their programming language are Microsoft amazon, cyberinfrastructures incorporated among many others. According to the pay scale, c-sharp developers with a few years of experience can earn nearly 102000 pa and in India, they can earn about 10 lakh rupees pa.

9. go

Next up we have to Go, Go is probably the least known of all programming languages discussed in this article. it was developed by Google in year 2007 for APIs and web applications. Go has recently become one of the fastest-growing programming languages due to its simplicity. Go popularly known as golang was created to meet the needs of programmers working on large projects. It has gained popularity among many large IT companies. Thanks to its simple and modern structure and syntax familiarity. The companies using Go as their programming language are google, uber, twitch, dropbox among many others according to glassdoor golang developers with a few years of experience can earn nearly seventy-five thousand dollars pa and in India, they can earn around 13 lakh rupees pa

8. C++

At number eight we have c++ in our list of Top Programming Languages In 2021, C++ is one of the most efficient and flexible programming languages. Even though it is a relatively old language when compared to others in this list. it has maintained its demand because of the high performance and reliability. C++ was built to support object-oriented programming and has rich libraries. C++ is used in the tech industry for various purposes like desktop application development, web, and mobile solutions game development, and even embedded systems. The companies using c++ as their programming language are adobe Microsoft, google among many others. C++ developers with a few years of experience can earn nearly one hundred thousand dollars pa and in India, they can earn around 12 lakh rupees ba according to glassdoor.

7. javascript

Next, we have the most popular programming language in the world javascript. javascript is the most popular language for web development today. Highly interactive and websites and web applications are powered by javascript. Javascript was the go-to language for front-end development. it still is but now it is also being used for server-side or back-end development. With the introduction of frameworks like node.js, the scope is also rapidly expanding in the areas of game development and the internet of things. The companies using javascript as their programming language are PayPal, Google, Microsoft among many others according to glassdoor javascript developers can easily earn up to 117 000 pa and in India, they can earn around 12 lakh rupees pa

6. swift

Next up we have Swift, Swift is a general-purpose open-source programming language developed by Apple. it is heavily influenced by python and therefore is fast and very easy to learn. Swift is majorly used for the development of native ios and mac os applications. Apple encourages the use of swift for the whole development process and so more than half of the applications in the app store is built using the Swift programming language. The companies using swift as their programming language are apple, slack,9gag among many others swift developers earn nearly 107000 pa and in India, they can earn around 12 lakh rupees pa

5. java

Another very popular language is java. So let’s look into it java was created by James Gosling in the year 1991 it is the most demanding programming language evident by its worldwide usage. Java is known for providing the most number of jobs in the IT industry. Java has a large application based in the industry with applications ranging from scientific applications, financial and banking services to web and mobile development and desktop application development. The companies using java as their programming language are IBM, HCL, Infosys among many others java developers with a few years of experience can earn nearly 117 000 pa, and in India, they can earn around 10 lakh rupees pa

4. R

Next up we have the R programming language, R was conceived by Robert gentleman and Ross ihaka in 1992. R is a comprehensive and statistical analysis language and it encourages developers to implement new ideas. R works best on Linux gnu and Microsoft windows. the application of R is in the field of data science, statistical computing, and machine learning. Although R is difficult to learn it is considered as the future programming language. The companies using R as their programming language are Capgemini, cognizant, Accenture among many others. R developers with a few years of experience can easily earn nearly 150 000 pa and in India, they can earn around 9 lakh rupees pa

3. kotlin

Moving on to number 3 we have in our list Top Programming Languages In 2021, we have Kotlin, Kotlin is a general-purpose programming language originally developed by JetBrains. It is interoperable with Java and also supports functional programming languages. Kotlin is used extensively for android development, web development, desktop application development, and server-side development. Kotlin was built to be better than java and people who use this language believe most of the google applications are based on Kotlin. The companies using Kotlin as their programming language are Coursera, Pinterest, postmates among many others according to glassdoor. Kotlin developers with a few years of experience can earn nearly 140 000 pa and in India, they can earn 8 lakh rupees pa.

2. php

Next, we have PHP, PHP programming language was initially created for the purpose of maintaining a personal website but since then it has taken over 24 websites globally. PHP language is generally used to create static and dynamic websites. Some popular web frameworks like laravel are built upon PHP. PHP introduces dynamic changes to a website and makes web applications more interactive. The companies using PHP as their programming language are Facebook, yahoo, Mailchimp among many others according to glassdoor. PHP developers can earn nearly 101 thousand dollars pa and in India, they can earn around seven lakh rupees pa on average.

1. python

In the first position, we have python programming language. Python is the fastest growing and one of the most popular programming languages with reliable and well-built frameworks. It is open-source and easy to learn python is used in many areas in the industry. Django framework which is based on python is popularly used in web development. Furthermore, Python has become the preferred programming language for machine learning and artificial intelligence. A few of the big companies that use python for development are Instagram, Spotify, Amazon, and Facebook. Python developers can earn nearly one hundred seven thousand dollars pa and in India, they can earn around eight lakh rupees pa.

End – Top Programming Languages In 2021

THANKS

Hope this will help you grow in your career and there you go those are the top 10 programming languages in 2021. With that, we’ve reached the end of this article. Do you agree with our top 10 list is there any other programming language that is worth learning in 2021. Let us know in the comments thank you for reading this article and stay tuned for more from simply learn

keep visiting : shaadcoding

0

Reverse string in Python in different ways

Reverse string in Python in different ways

Reverse string in Python in different ways – Python’s string library does not support built-in “reverse ()” like other Python wrappers, such as lists, so it can be helpful to understand other methods for reversing strings. This article introduces 5 different ways to invert strings in Python, so let’s get started.

1. using for loop

CODE:
def reverse(string):
str = ""
for i in range(len(string)-1,-1,-1):
str += string[i]
return str

str = "shaadcoding"
print("ORIGINAL STRING : ",str)
print("REVERSED STRING USING FOR LOOP : ",reverse(str))
OUTPUT:
ORIGINAL STRING :  shaadcoding
REVERSED STRING USING FOR LOOP : gnidocdaahs

2. using while loop

CODE:
def reverse(string):
i = len(string) - 1
str = ""
while i >= 0:
str += string[i]
i -= 1
return str
OUTPUT:
ORIGINAL STRING :  shaadcoding
REVERSED STRING USING WHILE LOOP : gnidocdaahs

3. using slice[] operator

CODE:
def reverse(string):
string = string[::-1]
return string
OUTPUT:
ORIGINAL STRING :  shaadcoding
REVERSED STRING USING SLICE[] : gnidocdaahs

4. using reversed() and join() function

CODE:
def reverse(string):
s = "".join(reversed(string))
return s
OUTPUT:
ORIGINAL STRING :  shaadcoding
REVERSED STRING USING reversed() AND join() function : gnidocdaahs

5. using recursion

CODE:
def reverse(string):
length = len(string)
if length == 0:
return string
else:
return reverse(string[1:]) + string[0]
OUTPUT:
ORIGINAL STRING :  shaadcoding
REVERSED STRING USING RECURSION:  gnidocdaahs

If you have another effective way to do this task. Regarding reverse strings in Python, please share them in the comments section.

You can also use Python or any other language. Share it in the comment section to help others

keep visiting : shaadcoding