0

Bank Management System in Python

Bank Management System Project in Python

Today we are going to build console based Bank Management System in Python

SO let get started our project,

Concepts Used:

Modules to imports

from random import randint

Account Class(parent class)

'''parent account class to be extending by three type of
accounts checking,business and saving'''
class Account:
#constructor to initialize class members
def __init__(self,firstName='',lastName='',uid='',address='',accType='',phoneNum='',initialBalance = 0.0):
self.firstName = firstName
self.lastName = lastName
self.uid = uid
self.address = address
self.accType = accType
self.phoneNum = phoneNum
self.initialBalance = initialBalance
def get_firstName(self):
return self.firstName

# setter method
def set_firstName(self, x):
self.firstName = x



def get_lastName(self):
return self.lastName

# setter method
def set_lastName(self, x):
self.lastName = x


def get_uid(self):
return self.uid

# setter method
def set_uid(self, x):
self.uid = x


def get_address(self):
return self.address

# setter method
def set_address(self, x):
self.address = x



def get_accType(self):
return self.accType

# setter method
def set_accType(self, x):
self.accType = x


def get_phoneNum(self):
return self.phoneNum

# setter method
def set_phoneNum(self, x):
self.phoneNum = x


def get_initialBalance(self):
return self.initialBalance

# setter method
def set_initialBalance(self, x):
self.initialBalance = x


def get_age(self):
return self.age

# setter method
def set_age(self, x):
self.age = x

'''This function will save the account holder info according to account type'''
def saveAccount(self):
'''This will check first account type then saves data according to it
It will generated random id and place account type key before it then appends the all user data to file'''
if self.get_accType() == 'c' or self.get_accType() == 'C':
secNum = randint(1000,10000)
secNum = 'che'+str(secNum)
print('your secret key is: ',secNum)
f= open("checkingAccount.txt","a+")
f.write(f"\n{self.get_firstName().replace(' ','_')} {self.get_lastName().replace(' ','_')} {self.get_uid().replace(' ','_')} {self.get_address().replace(' ','_')} {self.get_accType()} {self.get_phoneNum().replace(' ','_')} {secNum}")
f.close()
f1= open("checkingAccountBalance.txt","a+")
f1.write(f"\n{secNum} {self.get_initialBalance()}")
f1.close()
elif self.get_accType() == 's' or self.get_accType() == 'S':
secNum = randint(1000,10000)
secNum = 'sav'+str(secNum)
print('your secret key is: ',secNum)
f= open("savingAccount.txt","a+")
f.write(f"\n{self.get_firstName().replace(' ','_')} {self.get_lastName().replace(' ','_')} {self.get_uid().replace(' ','_')} {self.get_address().replace(' ','_')} {self.get_accType()} {self.get_phoneNum().replace(' ','_')} {secNum}")
f.close()
f1= open("savingAccountBalance.txt","a+")
f1.write(f"\n{secNum} {self.get_initialBalance()}")
f1.close()
elif self.get_accType() == 'b' or self.get_accType() == 'B':
secNum = randint(1000,10000)
secNum = 'bus'+str(secNum)
busiName = input('Enter your Business Name : ')
busiregNum = input('Enter your business registration number : ')
ownerName = input('Enter business owner name : ')
print('your secret key is: ',secNum)
f= open("businessAccount.txt","a+")
f.write(f"\n{self.get_firstName().replace(' ','_')} {self.get_lastName().replace(' ','_')} {self.get_uid().replace(' ','_')} {self.get_address().replace(' ','_')} {self.get_accType()} {self.get_phoneNum().replace(' ','_')} {secNum} {busiName.replace(' ','_')} {busiregNum.replace(' ','_')} {ownerName.replace(' ','_')}")
f.close()
f1= open("businessAccountBalance.txt","a+")
f1.write(f"\n{secNum} {self.get_initialBalance()}")
f1.close()
print(self.get_accType())

#This function will check id id randomly generated already present
def checkDuplication(self):
print(self.get_uid())
if self.get_accType() == 'c' or self.get_accType() == 'C':
with open('checkingAccount.txt','r') as f:
if self.get_uid() in f.read():
return True
elif self.get_accType() == 's' or self.get_accType() == 'S':
with open('savingAccount.txt','r') as f:
if self.get_uid() in f.read():
return True

elif self.get_accType() == 'b' or self.get_accType() == 'B':
with open('businessAccount.txt','r') as f:
if self.get_uid() in f.read():
return True

CheckingAccount class(child class of Account class)

#CheckingAccount class when is child class of Account class                    
class CheckingAccount(Account):
def displayAccount(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
#reading all data from file and matching user secret num to numbers in file,if it finds then it will show their info
f = open('checkingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
accdata = line
find = 1
f1 = open('checkingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
find = 1
if find == 1:
accdata = accdata.split()
name = accdata[0]+' '+accdata[1]
ide = accdata[2]
address = accdata[3].replace('_',' ')
accountType = 'Checking Account'
phone = accdata[5]
pin = accdata[6]
balance = accbalance.split()[-1]
print('Name : '+name)
print('Id : '+ide)
print('Address : '+address)
print('Account Type : ',accountType)
print('Phone Number : ',phone)
print('Balance : ',balance,' AED')

else:
print('No Account Found!')
tr = 1
return tr

def depositMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to deposit,user will enter amount then amount will be replace by adding new amount'''
f = open('checkingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('checkingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to deposit: '))
newbalance = balance + Balance
f1.close()
with open('checkingAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('checkingAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount deposited successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr

def withdrawMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to withdraw,user will enter amount then after validation amount will be replace by subtracting new amount'''
f = open('checkingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('checkingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to withdraw: '))
if Balance+100>balance:
print('Balance to withdraw must be less than Available balance(their must be AED 100 Always in Account)')
continue

newbalance = balance - Balance
f1.close()
with open('checkingAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('checkingAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount withdrawn successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr
#This method will read balance from account,and calculates 3% interest
def callInterest(self,secNum):
find = 0
accdata = ''
accbalance = ''
balance = 0.0
tr = 1
f = open('checkingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
f1 = open('checkingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
print('your interest per annum is : ',(3/100)*balance,' AED')
tr = 0
else:
print('No Account Found!')
return tr

SavingAccount Class(child class of Account class)

#SavingAccount class when is child class of Account class
class SavingAccount(Account):
#reading all data from file and matching user secret num to numbers in file,if it finds then it will show their info
def displayAccount(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
f = open('savingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
accdata = line
find = 1
f1 = open('savingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
find = 1
if find == 1:
accdata = accdata.split()
name = accdata[0]+' '+accdata[1]
ide = accdata[2]
address = accdata[3].replace('_',' ')
accountType = 'Saving Account'
phone = accdata[5]
pin = accdata[6]
balance = accbalance.split()[-1]
print('Name : '+name)
print('Id : '+ide)
print('Address : '+address)
print('Account Type : ',accountType)
print('Phone Number : ',phone)
print('Balance : ',balance,' AED')
else:
print('No Account Found!')
tr = 1
return tr
def depositMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to deposit,user will enter amount then amount will be replace by adding new amount'''
f = open('savingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('savingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to deposit: '))
newbalance = balance + Balance
f1.close()
with open('savingAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('savingAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount deposited successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr

def withdrawMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to withdraw,user will enter amount then after validation amount will be replace by subtracting new amount'''

f = open('savingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('savingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to withdrawn: '))
if Balance+1000>balance:
print('Balance to withdraw must be less than Available balance(their must be AED 100 Always in Account)')
continue

newbalance = balance - Balance
f1.close()
with open('savingAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('savingAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount withdrawn successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr
#This method will read balance from account,and calculates 7% interest
def callInterest(self,secNum):
find = 0
accdata = ''
accbalance = ''
balance = 0.0
tr = 1
f = open('savingAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
f1 = open('savingAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
print('your interest per annum is : ',(7/100)*balance,' AED')
tr = 0
else:
print('No Account Found!')
return tr

BusinessAccount Class(child class of Account class)

#BusinessAccount class when is child class of Account class
class BusinessAccount(Account):
#reading all data from file and matching user secret num to numbers in file,if it finds then it will show their info
def displayAccount(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
f = open('businessAccount.txt','r')
for line in f.readlines() :
if secNum in line :
accdata = line
find = 1
#print(accdata)
f1 = open('businessAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
find = 1

if find == 1:
accdata = accdata.split()
name = accdata[0]+' '+accdata[1]
ide = accdata[2]
address = accdata[3].replace('_',' ')
accountType = 'Business Account'
phone = accdata[5]
bname = accdata[6]
brn = accdata[7]
bon = accdata[8]
balance = accbalance.split()[-1]
print('Name : '+name)
print('Id : '+ide)
print('Address : '+address)
print('Account Type : ',accountType)
print('Phone Number : ',phone)
print('Balance : ',balance,' AED')
print('Business Name : ',bname)
print('Business Registration Number : ',brn)
print('Business owner Name : ',bon)
else:
print('No Account Found!')
tr = 1
return tr
def depositMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to deposit,user will enter amount then amount will be replace by adding new amount'''
f = open('businessAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('businessAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to deposit: '))
newbalance = balance + Balance
f1.close()
with open('businessAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('businessAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount deposited successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr


def withdrawMoney(self,secNum):
find = 0
accdata = ''
accbalance = ''
tr = 0
'''reading all data from file and matching user secret num to numbers in file,
if it finds then it will ask for amount to withdraw,user will enter amount then after validation amount will be replace by subtracting new amount'''
f = open('businessAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
while True:
try:
f1 = open('businessAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
Balance = float(input('Enter balance to withdrawn: '))
if Balance+2000>balance:
print('Balance to withdraw must be less than Available balance(their must be AED 100 Always in Account)')
continue

newbalance = balance - Balance
f1.close()
with open('businessAccountBalance.txt', 'r') as file :
filedata = file.read()

# Replace the target string
filedata = filedata.replace(str(balance), str(newbalance))

# Write the file out again
with open('businessAccountBalance.txt', 'w') as file:
file.write(filedata)
print('Amount withdrawn successfuly!')
break
except ValueError:
print('invalid input!')
else:
print('No Account Found!')
tr = 1
return tr
#This method will read balance from account,and calculates 3% interest
def callInterest(self,secNum):
find = 0
accdata = ''
accbalance = ''
balance = 0.0
tr = 1
f = open('businessAccount.txt','r')
for line in f.readlines() :
if secNum in line :
find = 1
if find == 1:
f1 = open('businessAccountBalance.txt','r')
for line in f1.readlines() :
if secNum in line :
accbalance = line
balance = float(accbalance.split()[-1])
print('your interest per annum is : ',(3/100)*balance,' AED')
tr = 0
else:
print('No Account Found!')
return tr

main method to start execution

def main():
ch=''
num=0
#creating files to read and write data
f1 = open("checkingAccountBalance.txt", "a+")
f2 = open("savingAccountBalance.txt", "a+")
f3 = open("businessAccountBalance.txt", "a+")
f4 = open("checkingAccount.txt", "a+")
f5 = open("savingAccount.txt", "a+")
f6 = open("businessAccount.txt", "a+")
while ch != '6':
#display menu
print("MAIN MENU")
print("1. OPEN ACCOUNT")
print("2. DISPLAY AMOUNT")
print("3. DEPOSIT AMOUNT")
print("4. WITHDRAW AMOUNT")
print("5 CHECK INTEREST")
print("6. EXIT")
print("\tSelect Your Option (1-6) ")
ch = input()
if ch == '1':
try:
#user will enter required data to open account
initialBalance = 0.0
firstName = input('Enter your first name :')
lastName = input('Enter your last name :')
uid = input('Enter your id number :')
address = input('Enter your address: ')
while True:
accType = input('Enter your Account Type:[c = Checking Account,s = Saving Account,b = Business Account] ')
if accType == 'c' or accType == 'C' or accType == 's' or accType == 'S' or accType == 'b' or accType == 'B':
break
else:
print('invalid Account Type!')
print("Enter 'c' = Checking Account,'s' = Saving Account,'b' = Business Account")
continue
phoneNum = input('Enter your Phone Number :')
#loop will continues untill user enter valid amount
while True:
try:
initialBalance = float(input('Enter intial balance(AED) : '))
if accType == 'c' or accType == 'C':
if initialBalance<100:
print('balance should be greater than 100')
continue
else:
break
elif accType == 's' or accType == 'S':
if initialBalance<1000:
print('balance should be greater than 1000')
continue
else:
break
elif accType == 'b' or accType == 'B':
if initialBalance<2000:
print('balance should be greater than 2000')
continue
else:
break


except ValueError:
print('invalid input!')
if not firstName or not lastName or not uid or not address or not accType or not phoneNum or not initialBalance:
print('Fill all required feilds!')
raise ValueError
input('Enter to continue... ')
a = Account(firstName,lastName,uid,address,accType,phoneNum,initialBalance)
if a.checkDuplication():
print(f'Account with id number {uid} already exist')
continue
a.saveAccount()
except ValueError:
print('invalid input!')
#this will display account of user after user will enter its secret number
elif ch == '2':
tryi = 3
tr = 1
while tryi>0:
secNum = input('Enter your secret Number :')
secNum = secNum.lower()
if secNum[0] == 'c':
c = CheckingAccount()
tr = c.displayAccount(secNum)
elif secNum[0] == 's':
c = SavingAccount()
tr = c.displayAccount(secNum)
elif secNum[0] == 'b':
c = BusinessAccount()
tr = c.displayAccount(secNum)
else:
print('invalid Number!')
if tr == 0:
break
elif tr == 1:
tryi -= 1
if tryi == 0:
print('3 tries done!')
#this will deposit money after user will enter its secret number
elif ch == '3':
tryi = 3
tr = 1
while tryi>0:
secNum = input('Enter your secret Number :')
secNum = secNum.lower()
if secNum[0] == 'c':
c = CheckingAccount()
tr = c.depositMoney(secNum)
elif secNum[0] == 's':
c = SavingAccount()
tr = c.depositMoney(secNum)
elif secNum[0] == 'b':
c = BusinessAccount()
tr = c.depositMoney(secNum)
else:
print('invalid Number!')
if tr == 0:
break
elif tr == 1:
tryi -= 1
if tryi == 0:
print('3 tries done!')

#this will withdraw money after user will enter its secret number
elif ch == '4':
tryi = 3
tr = 1
while tryi>0:
secNum = input('Enter your secret Number :')
secNum = secNum.lower()
if secNum[0] == 'c':
c = CheckingAccount()
tr = c.withdrawMoney(secNum)
elif secNum[0] == 's':
c = SavingAccount()
tr = c.withdrawMoney(secNum)
elif secNum[0] == 'b':
c = BusinessAccount()
tr = c.withdrawMoney(secNum)
else:
print('invalid Number!')
if tr == 0:
break
elif tr == 1:
tryi -= 1
if tryi == 0:
print('3 tries done!')
break
#this will calculate interest rate after user will enter its secret number
elif ch == '5':
tryi = 3
tr = 1
while tryi>0:
secNum = input('Enter your secret Number :')
secNum = secNum.lower()
if secNum[0] == 'c':
c = CheckingAccount()
tr = c.callInterest(secNum)
#print(tr)
elif secNum[0] == 's':
c = SavingAccount()
tr = c.callInterest(secNum)
elif secNum[0] == 'b':
c = BusinessAccount()
tr = c.callInterest(secNum)
else:
print('invalid Number!')
if tr == 0:
break
elif tr == 1:
tryi -= 1
if tryi == 0:
print('3 tries done!')
break

Finally calling main method

if __name__=='__main__':
main()

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

2

Tic Tac Toe GUI based game in python Tkinter

tic tac toe using python tkinter module gui based

topic – tic toe game in python tkinter

Learning Outcomes

  • Implement Tkinter GUI Python Application
  • Implement and utilize widgets
  • Develop logic

Program Overview – tic toe game in python tkinter

Your task is to build the game Tic Tac Toe in a GUI application. The form consists of 9 buttons that each player takes turns clicking trying to mark 3 in a row. Player 1 goes first and will mark a button with an X. Next Player 2 takes a turn marking a button with an O. The winner is the first to get 3 marks in a row, column, or diagonal. If all 9 buttons are marked and no winner, declare a message which is a tie. After a game (win or tie), reset the board and start over with player 1’s turn.

It is recommended to use functions to keep your code to a minimum.

tic tac toe python code for beginners continue…

Functionality Requirements

Your game should:

  1. Create a GUI that has 9 buttons. Consider ways to store the buttons in a way that allow you to access them and modify the buttonObject.config(text=’X or O’) field to Mark the button for player 1 or 2. If you were to store all button in a structure that has an index of some kind you could easily determine which button is being clicked. You’ll need some way to know the button that was clicked was the upper left which is index 0 (this is an example).
  2. Create a function to link the click event for all buttons. This event handler must be invoked when any of the 9 buttons are clicked and I suggest using a lambda to allow you the ability to pass data to indicate which button was pressed similar to how you did the calculator. Follow the provided psuedo-code to complete the code. Declare variables for the needed information. The process of the game is players alternate turns clicking a button (player 1 goes first and marks X while player 2 marks O). Each button click is the exact same logic which follows:
    • Determine which player is taking a turn (clicking the button)
      • If player 1, change the button text to X and state to DISABLED
      • If player 2, change the button text to O and state to DISABLED
    • Change Players alternating players each turn
    • Keep a count of the number of turns taken place because only 9 turns are possible at which point you have a cats game or tie.
  3. Create a function check_for_winner. Complete the following:
    • Create a decision to check for all possible winning combinations.
    • Things to consider to perform this operation:
      • Which player are we checking won?
      • Which buttons has this player selected? You could check all buttons for their mark (X or O), or maybe you stored this players marks in a data structure saving a number to specify the button location.
      • Know the winning combinations. Example I could create a number system for the game board like below:
        • 012
        • 345
        • 678
        • So combos are: 012, 036, 048, etc.

Now, does the player your checking have any of these combos, but if you find 1 the game is over.

Note: After each user moves, the program needs to check if the user has won or not. There are 8 ways a user can win. He or she can complete any one of the 3 rows, or the 3 columns, or the 2 diagonals. If the game has been won, as determined by this method, clear_board() and reset the game data to the beginning.

CODE – tic toe game in python tkinter:

import tkinter as tk


player1Color = "tomato"
player2Color = "sea green"
textColorPlayer1 = "sea green"
textColorPlayer2 = "tomato"
labelColor = "orange"
labelTextColor = "blue"
btnResetColor = "black"
btnResetTextColor = "grey"


'''This function will be called when user
click on RESET button
This function will clear all the text on
button and set color to default
outer loop is for rows and while inner loop
is for columns it will reset all 9 buttons'''
def reset():
for i in range(3):
for j in range(3):
board[i][j].configure(text='',
bg="SystemButtonFace")


'''This function will be called when ever user
played any move,it will check if any of
condition is fullfilled or not
if condition is fullfilled then return 1
if still no one has won it will return
0 and if the games draw it will return -1'''
def isWin():
for i in range(3):
if board[i][0]['text'] == board[i][1]['text'] \
== board[i][2]['text'] != '':
return 1
for j in range(3):
if board[0][j]['text'] == board[1][j]['text'] \
== board[2][j]['text'] != '':
return 1
if board[0][0]['text'] == board[1][1]['text'] \
== board[2][2]['text'] != '':
return 1
elif board[0][2]['text'] == board[1][1]['text'] \
== board[2][0]['text'] != '':
return 1
elif EmptyCells() == []:
return 0
else:
return -1


#this function will return empty list of all
# the buttons which are stilled on used by player
def EmptyCells():
h=[]
for i in range(3):
for j in range(3):
#it will check if button has not any text on it
if board[i][j]['text'] == '':
h.append((i,j))
return h

#for first run first player will be given
# character 'O'
player = 'O'

#here's the main flow of game
def main_gameflow(r,c):
#global variable player to
# store currentplayer
#it is global because global
# variable can be access from any where in program
global player
#if current button on board is empty the
# it will add respected text on button i.e: O or X and after move checks if anyone wins

if board[r][c]['text'] == '' and isWin() == -1:
if player == 'O':
board[r][c].configure(text='O',bg = player1Color, fg= textColorPlayer1)
if isWin() == -1:
player = 'X'
winAndTurnLabel.configure(text=("It's X's turn"))
elif isWin() == 1:
winAndTurnLabel.configure(text=("O win"))
elif isWin() == 0:
winAndTurnLabel.configure(text="Draw!")
elif player == 'X':
board[r][c].configure(text='X',bg = player2Color, fg= textColorPlayer2)
if isWin() == -1:
player = 'O'
winAndTurnLabel.configure(text=("It's O's turn"))
elif isWin() == 1:
winAndTurnLabel.configure(text=("X win"))
elif isWin() == 0:
winAndTurnLabel.configure(text="Draw!")

#making Tkinter object
screen=tk.Tk()
#setting screen title
screen.title('Tic Tac Toe')
#creating 3 * 3 matrix
board=[[0,0,0],[0,0,0],[0,0,0]]
#generating buttons with 3 rows and 3 columns and
#each row and columns will contain 3 buttons
for i in range(3):
for j in range(3):
#creating button where command takes an lambda funtion
#means lambda is any funtion which will be exexuted whenever any button is clicked
board[i][j]=tk.Button(text='',font=('normal',60,'normal'),width=4,height=1,command=lambda row = i,col = j: main_gameflow(row,col))
#placing button in grid so their will be no space between buttons
board[i][j].grid(row=i,column=j)

#generating label to tell which player turn and who wins / Draw
winAndTurnLabel=tk.Label(text="It's O's turn",font=('normal',22,'bold')
,bg = labelColor,fg = labelTextColor)
winAndTurnLabel.grid(row=3,column=1)
#Generating Reset button to reset game / board
ResetButton=tk.Button(text='RESET',font=('Courier',18,'bold')
,fg=btnResetTextColor,bg = btnResetColor,command=reset)
ResetButton.grid(row=4,column=1)
screen.mainloop()

DEMO

Tags :

tic toe game in python Tkinter
tic tac toe python tkinter
2 player tic tac toe python beginner

keep visiting : shaadcoding

0

implementation of encryption using python

implementation of encryption using python

implementation of encryption using python – You realized that your encryption method is too naive, now you want to change your and make it more sophisticated. You came up an idea that to move each plaintext character k steps forward to become another character. For example, if k = 4, 4 steps forward of the character ‘a’ is ‘e’, and 4 steps forward of the character ‘b’ is ‘f’.

cipher4

In [ ]:

# Hints
# you can convert "a" to number 1 by thinking a 36-decimal system 
# (we borrow the idea of hexdecimal system). i.e. a=10, b=11, ... z=35

int("a", 36)

Out[ ]:

10

In [ ]:

# test for "z"
int("z", 36)

Out[ ]:

35

Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as ‘a’ or ‘@’ or an action of some sort.

Given the following ASCII table:

DecChrDecChrDecChr
97a106j115s
98b107k116t
99c108l117u
100d109m118v
101e110n119w
102f111o120x
103g112p121y
104h113q122z
105i114r

You can find out more about ASCII code here: ASCIIIn [ ]:

chr(97)

Out[ ]:

'a'

In [ ]:

# you can do a conversion from number to character by the following sample code
# In your 36-decimal system, 10 represent and "a", and you know that 97 represent "a" in ASCII system, 
# so you can simply add 87 (97-10) to get your character in your 36-decimal system.

value = int("a", 36)  ## it give your value of 10
value = value - 10    ## it is better to shift your character in a range of 1-25, instead of 10-35
chr(value+97)   ## it should give you back character "a", We only use the ASCII table in the range of 97 to 122.

Out[ ]:

'a'

Implement the encryption algorithm and named your function as encrpt2. Take one argument as the input and one argument contains the value k. You only require to handle lowercase character. You NO need to handle special character such as space bar.In [30]:

# implementation of encryption using python

# k = 4 is for testing, your program should work for any value of n

k = 4

def encrypt2(input, k):
    output = ""    
# write your program below:
    for c in input:
        value = int(c, 36)
        value = value - 10
        if value+k > 25:
            value = value-26
        value = value+97+k
        c = chr(value)
        output += c
    return output

In [31]:

# test your function
encrypt2("abcdefghijklmnopqrstuvwxyz", 1)

Out[31]:

'bcdefghijklmnopqrstuvwxyza'

In [32]:

# test your function
encrypt2("abcdefghijklmnopqrstuvwxyz", 4)

Out[32]:

'efghijklmnopqrstuvwxyzabcd'

If you have another efficient way to do this, please share in the comment section.

If you have also done the same(implementation of encryption using python) in python or any other language works. Share it in the comments section to help others

keep visiting : shaadcoding

1

simple substitution cipher implementation using Python

substitution cipher implementation using Python

substitution cipher implementation using Python – You want to develop a secret communication method with your friend. One day, you read a book about a simple substitution cipher and you want to implement it by using Python.

The logic of substitution cipher implementation using Python is easy. Your friend and you came up with the following naive substitution algorithm.

cipher3

That is, you swap characters “a” with “c”, “d” with “q”, “i” with “m”, and “t” with “y”. Other characters leave unchanged.

Based on your algorithm, a plaintext “raymond” will be encrypted as “rctionq”.

Implement the encryption algorithm and named your function as encrpt. Take one argument as the input and one argument contains the key pairs. You only require to handle lowercase character.

A two-dimension array is used to represent the key-value pairs.

keys = [["a", "c"], ["c", "a"], ["d", "q"], ["i", "m"], ["m", "i"], ["q", "d"], ["t", "y"], ["y", "t"]]

You can access the first key pair by keys[0]In [ ]:

keys = [["a", "c"], ["c", "a"], ["d", "q"], ["i", "m"], ["m", "i"], ["q", "d"], ["t", "y"], ["y", "t"]]

keys[0]

Out[ ]:

['a', 'c']

The first key can be obtained by keys[0][0]In [ ]:

keys[0][0]

Out[ ]:

'a'

The first value of key “a” can be obtained by keys[0][1]In [ ]:

keys[0][1]

Out[ ]:

'c'

The last pair of key can be obtained by the following example code:In [ ]:

last = len(keys)   # last = 8
print(keys[(last-1)])     # the first index is 0, the last index is 7. and this will give you a list of ["y", "t"]

# assign the last keypair to a variable named temp
temp = keys[(last-1)]
print(temp)     # it will give you the same ouput as above

print(temp[0])  # "y"
print(temp[1])  # "t"
['y', 't']
['y', 't']
y
t

You can test your function by checking the following input-output pairs.
Input: “raymond”
Ouput: “rctionq”


Input: “peter is a good guy”
Output: “peyer ms c gooq gut”

if you really can’t use a flexible way to implement the code, you can forget about the keys variable and use if-else statements to complete itIn [11]:

# implementation


keys = [["a", "c"], ["c", "a"], ["d", "q"], ["i", "m"], ["m", "i"], ["q", "d"], ["t", "y"], ["y", "t"]]

input = "raymond"

def encrypt(input, keys):
    output = ""

    # Write your code below:
    for c in input:
        for k in keys:
            if c == k[0]:
                c = k[1]
                break
        output += c
    return output
                
            

In [12]:

# Test your function
encrypt("raymond", keys)

Out[12]:

'rctionq'

If you have another efficient method, please share the comment section.

If you have also used python or any other language to do your work. Share it in the comments section to help others

keep visiting : shaadcoding

0

hexadecimal to decimal in python(Easy Solution)

hexadecimal to decimal in python

hexadecimal string to a decimal value in python – Write a function that converts the hexadecimal string to a decimal value. You can NOT use any Python library/module to help you do it. Your function name should be named hex and take one argument as the input.

In mathematics and calculations, the hexadecimal number system (also 16 or hexadecimal) is a positional number system that uses the base 16 to represent numbers. Unlike the usual way of using 10 symbols to represent numbers, hexadecimal uses 16 different symbols. In most cases, the symbols “0” – “9” represent values ​​from 0 to 9 and “A” – “F” (or “A” – “f”) represent values ​​from 10 to 15.

The decimal numeral system (also called the base-ten positional numeral system, and occasionally called denary/ˈdiːnəri/[1] or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers of the Hindu–Arabic numeral system.[2] The way of denoting numbers in the decimal system is often referred to as decimal notation.[3]

For example, if the input is “F23A”, the decminal value is 62010 and the procedure in the conversion is at below:

QUESTION 2

Hints: you can use int('A', 16) to convert a hex string value to dec integer. Also, you can use funtion len(input) to find out the length of the string. You can extract a particular character in a string by specifying an index.

# Below codes are hints
# exmaple

a = "F23A"
print(len(a))
print(a[3])
print(int(a[3],16))
4
A
10

In [8]:

# Implementation

input = "F23A"

# Start the code below
def hex(s):
    l = len(s) - 1
    d = 0
    for c in s:
        res = int(c,16)*(16**l)
        d += res
        l -= 1
    return d
        
  

In [9]:

# test your code here
input = "F23A"
hex(input)

Out[9]:

62010

If you have another efficient method, please share the comment section.

If you also use Python or any other language to do your work(hexadecimal string to a decimal value in python). Share it in the comment section to help others

keep visiting : shaadcoding

0

List of Even numbers below a certain value in python.

List of Even numbers in python

Topic – List of Even numbers below a certain value in python

EXPLANATION:

For example, if k = 16, your function should return a list of [2,4,6,8,10,12,14]

Name your function as even_list() that takes one argument named k.In [ ]:

# hints:
# you can create an empty list and append items on it by the following code:

a = []
a.append(4)
a.append(6)
print(a)
[4, 6]

In [4]:

let’s start – List of Even numbers below a certain value in python

List of Even numbers in python – CODE

# Implementation

# write your code below
def even_list(k):
    even = []
    for i in range(1,k):
        if i % 2 == 0:
            even.append(i)
    return even

In [5]:

# test your function here
even_list(16)

Out[5]:

[2, 4, 6, 8, 10, 12, 14] 

If you have another efficient method, please share the comment section.

If you also use Python or any other language to complete the job. Share it in the comment section to help others

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

0

Find a specific term in all files using python

How to find a specific term in all files of the local disk using python find a term in all files using python find string in all files using python Search string in all files of directory or subdirectories Search files with specific string/term using python print path of files with specific string/term using python

Problem Statements:

  • How to find a specific term in all files of the local disk using python
  • find a term in all files using python
  • find string in all files using python
  • Search string in all files of directory or subdirectories
  • Search files with specific string/term using python
  • print path of files with specific string/term using python

Sometimes we forgot a file path but we know that we have done the same work before, We just have some clues that the file contained a specific term or string, So how can we use the clues of string or term to find the path of that file? So today I will tell you how to search a specific string/term in all files using python of the current directory or subdirectories.

So let get started our article of how to search a file with specific term/string.

CODE(Find a specific term in all files using python):

import os
from fnmatch import fnmatch

term = input("Enter term to find in files : ")
found = 0
formats = ['.txt','.csv','.docs','docx']
for path, subdirs, files in os.walk(os.getcwd()):
    for name in files:
        if name.lower().endswith(tuple(formats)):
            path = os.path.join(path, name)
            try:
                f = open(path)
                for line in f.readlines():
                    if term in line:
                        print(path)
                        found = 1
                        break
            except Exception as e:
                pass

if found == 0:
    print("No file found with term = ",term)

DEMO:

Save the python file in the directory where you want to search the files with a specific term/string and just run it, It will ask for a term to search and then prints all files with that input string/term, If any file does not contain that term/string then it will print a message

"No file found with term = "{term}

If you have another effective way of doing this task. To use Python to find files containing text / strings or specific terms, share in the comments section.

If you have also done the same in python or any other language the construction site. Share it in the comment section to help others

keep visiting : shaadcoding