Python Aat Sukruthi KC

Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

BMS COLLEGE OF ENGINEERING

(Autonomous college under VTU)


Bull Temple Rd, Basavanagudi, Bengaluru, Karnataka
5600192020
Department of Computer Applications

Report is submitted for the fulfillment of the AAT Work in the subject
“Python Programming”
(22MCA1PCPY)
Of
I Semester
MCA

By

Name of Student: Sukruthi KC( )

Date of Submission: 13/5/2023

Under the Guidance

RV RAGHAVENDRA RAO
(Assistant Professor)
TABLE OF CONTENTS

1. Python program to check whether the given number is even or not.


2. Python program to convert the temperature in degree centigrade to Fahrenheit.
3. Python program to find the area of a triangle whose sides are given.
4. Python program to find out the average of a set of integers.
5. Python program to find the product of a set of real numbers.
6. Python program to find the circumference and area of a circle with a given radius.
7. Python program to check whether the given integer is a multiple of 5.
8. Python program to check whether the given integer is a multiple of both 5 and 7.
9. Python program to find the average of 10 numbers using while loop.
10. Python program to display the given integer in a reverse manner 11
11.Python program to find the geometric mean of n numbers
12.Python program to find the sum of the digits of an integer using a while loop
13.Python program to display all the multiples of 3 within the range 10 to 50
14.Python program to display all integers within the range 100-200 whose sum of digits is
an even number
15. Python program to check whether the given integer is a prime number or not
16. Python program to generate the prime numbers from 1 to N
17. Python program to find the roots of a quadratic equation
18. Python program to print the numbers from a given number n till 0 using recursion
19.Python program to find the factorial of a number using recursion
20. Python program to display the sum of n numbers using a list
21.Python program to find largest numbers in a list without using built in functions
22. Python program to remove @gmail.com to @bmsce.ac.in in all email ids (Consider
minimum 10 email ids)
23. Python program to pick first letters as names and printing as names.

24. Develop a program to print non-eligible student roll num and percentage of attendance
by using dictionary Comprehension Consider the dictionary Attendance = {‘01’:60,
‘02’:76, ‘03’:34, ‘08’:77, ‘04’:75, ‘05’:80, ‘06’:100} With student id, percentage as key
value pair and 75 is the required percentage to get eligibility.

25. Find the min and max score of a subject by using dictionary comprehension Consider
the following data Marks = {‘OS’:[10,12,8,19], ‘python’:[8,12,9,15,14],
‘DSA’:[23,77,12,6,12], ‘MFCA’:[8,9,12,17], ‘COA’:[12,15,17,19] }

26. Create a Python class called Bank Account which represents a bank account, having as
attributes: accountNumber (numeric type), Name (name of the account owner as a string
type), balance. Create a constructor with the accountNumber, name, and balance
parameters. Create a Deposit() method that manages the deposit actions. Create a
Withdrawal() method that manages withdrawal actions. Create a bankFees () method to
apply the bank fees with a percentage of 5% of the balance account. Create a display()
method to display account details.

27. Create a function that takes a number as an argument, increments the number by +1 and
returns the result.

28. Write a program to calculate the age of the user, by receiving the user's DOB as input
and using functions.

29. Develop a program for conversion. CM to Inches (and vice versa), Meters to
Kilometers (and vice versa), Grams to Kilograms (and vice versa). Initially, you need to
collect input from the user by displaying the above options for conversion procedures and
perform accordingly.

30. "A Bachelor of Engineering in Computer Science from BMS College of Engineering in
Karnataka, 29-year-old Amrith was part of the National Cadet Corps's Republic Day team
in 2008 and harboured the dream of being part of the marching contingents of one of the
three services at the celebrations in Delhi." Apply all possible string handling operations to
the above data. Identify the length of the data, number of words, and print each word and
how many times it appeared in the data shared

31. Perform operations using numpy and panda for datasets

32. Data visualization ,tkinter and database


22MCA1PCPY:Python Programming

1) Python program to check whether the given number is even or not.


num = 25
if num %2 == 0:
print("Entered number is even")
else:
print("Entered number is odd")

OUTPUT:

2) Python program to convert the temperature in degree centigrade to Fahrenheit.

def convert(c):
f = (9.5)*c + 32
return(F)
cel=float(input("Enter the temperature: "))fah=convert(cel)
print("The temperature in fahrenheit is",Fah)

OUTPUT:

Department of Computer Applications,BMSCE Page 2


22MCA1PCPY:Python Programming

3) Python program to find the area of a triangle whose sides are given

a =float(input("enter the first side: "))


b=float(input("enter the second side:"))
c =float(input("enter the third side:"))
s=(a+b+c)/2
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print("The area of the triangle is ",area

OUTPUT:

Department of Computer Applications,BMSCE Page 3


22MCA1PCPY:Python Programming

4) Python program to find out the average of a set of integers

I = int(input("enter numbers = "))


sum = 0
for i in range(l):
x = int(input("enter num ="))
sum = sum + x
avg = sum / l
print("avg=",avg)

OUTPUT:

5) Python program to find the product of a set of real numbers.

p=0
product = 1
count = int(input("Enter numbers="))for i in
range(count):
x = float(input("Enter num="))
product = product * x
print("product is=",product)

OUTPUT

Department of Computer Applications,BMSCE Page 4


22MCA1PCPY:Python Programming

6) Python program to find the circumference and area of a circle with a


given radius

pi=3.14
r=int(input("enter the radius of circle: "))

y=input("what you want to find first area or circumference? ")if


y=='area':
print("the area of circle is: ",pi*r*r)
else:
print("the circumference of circle:",2*pi*r)
OUTPUT

7) Python program to check whether the given integer is a multiple of 5.

y= int(input("Type number="))
if(y%5==0):
print("Yes")
else:
print("No")

OUTPUT

Department of Computer Applications,BMSCE Page 5


22MCA1PCPY:Python Programming

8) Python program to check whether the given integer is amultiple of both 5


and 7.

y=int(input("Enter the number you want to check?"))if


y%5==0 and y%7==0:
print("the number "+ str(y)+ " is multiple of 5 and 7")else:
print("the number " + str(y) + " is not multiple of 5 and 7")

OUTPUT:

Department of Computer Applications,BMSCE Page 6


22MCA1PCPY:Python Programming

9) Python program to find the average of 10 numbers using while loop.

print("Enter the 10 numbers:")sum = 0


count = 0

while count<10:
n = float(input("Number " + str(count + 1) + ": "))sum = sum + n
count = count + 1
average = sum/10
print(f 'The average of these numbers is: {average}')

OUTPUT:

Department of Computer Applications,BMSCE Page 7


22MCA1PCPY: Python Programming

10) Python program to display the given integer in a reverse


manner.

o = 9724
rev = 0
while(o<0):
a = o %10
rev = rev * 10 + ao = o
// 10
print(rev)

OUTPUT

Department of Computer Applications,BMSCE Page 8


22MCA1PCPY:Python Programming

11) Python program to find the geometric mean of n numbers

numbers = []
n=int(input("Enter the range"))
for i in range(n):
j=int(input("Enter number "+str(i+1)+":"))
numbers.append(j)

largest = numbers[0]
for num in numbers[1:]:
if num > largest:
largest = num

print("The largest number in the list is:", largest)


OUTPUT

Department of Computer Applications,BMSCE Page 9


22MCA1PCPY:Python Programming

12) Python program to find the sum of the digits of an integer using a while loop

def sum1():
sum = 0
number = int(input("Enter an integer: "))
while(number!=0):
digit = number%10
sum = sum+digit
number = number//10
print("Sum of digits is: ", sum)

sum1()

OUTPUT:

13) Python program to display all the multiples of 3 within the range 10 to 50

for i in range(10,50):
if (i%3==0):
print(i)

Department of Computer Applications, BMSCE Page 10


22MCA1PCPY:Python Programming

OUTPUT:

14)Python program to display all integers within the range 100-200 whose sum of
digits is an even number

for i in range(100,200):
num = i
sum = 0
while(num!=0):
digit = num%10
sum = sum + digit
num = num//10
if(sum%2==0):
print(i)
OUTPUT:

Department of Computer Applications, BMSCE Page 11


22MCA1PCPY:Python Programming

Department of Computer Applications, BMSCE Page 12


22MCA1PCPY:Python Programming

15) Python program to check whether the given integer is a prime number or not

num = int(input("Enter an integer"))


if (num)>0:
prime=1
for i in range(2,num//2):
if (num%i==0):
prime = 0
break
if(prime==1):
print(num, "is a prime number")
else:
print(num, "is not a prime number")
else:
print("enter number which is greater than 1")

OUTPUT:

Department of Computer Applications,BMSCE Page 13


22MCA1PCPY:Python Programming

16) Python program to generate the prime numbers from 1 to N

num =int(input("Enter the range: "))


for n in range(2,num):
for i in range(2,n):
if(n%i==0):
break
else:
print(n)

OUTPUT:

Department of Computer Applications,BMSCE Page 14


22MCA1PCPY:Python Programming

17) Python program to find the roots of a quadratic equation

import math
a = float(input("Enter the first coefficient: "))
b = float(input("Enter the second coefficient: "))
c = float(input("Enter the third coefficient: "))
if (a!=0):
d = (b*b)-(4*a*c)
if (d==0):
print("The roots are real and equal.")
r = -b/(2*a)
print("The roots are ", r,"and", r)
elif(d>0):
print("The roots are real and distinct.")
r1 = (-b+(math.sqrt(d)))/(2*a)
r2 = (-b-(math.sqrt(d)))/(2*a)
print("The root1 is: ", r1)
print("The root2 is: ", r2)
else:
print("The roots are imaginary.")
realpart = -b/(2*a)
imaginarypart = math.sqrt(-d)/(2*a)
print("The root1 is: ", realpart, "+ i",imaginarypart)
print("The root2 is: ", realpart, "- i",imaginarypart)
else:
print("Not a quadratic equation.")

OUTPUT:

Department of Computer Applications,BMSCE Page 15


22MCA1PCPY:Python Programming

Department of Computer Applications,BMSCE Page 16


22MCA1PCPY:Python Programming

18) Python program to print the numbers from a given number n till 0 using
recursion

def count(n):
if n >= 0:
count(n - 1)
print(n)
num=int(input("Enter the number"))
count(num)

OUTPUT:

19) Python program to find the factorial of a number using recursion

def fact(n):
if n==1:
return 1
else:
return n * fact(n-1)

num = int(input("Enter an integer:"))


result = fact(num)

Department of Computer Applications,BMSCE Page 17


22MCA1PCPY:Python Programming

print("The factorial of", num, " is: ", result)


OUTPUT:

20) Python program to display the sum of n numbers using a list

total = 0
numbers=[]
num = int(input("Enter the range"))
for n in range(num):
x = int(input("Enter number"))
numbers.append(x)
for ele in range(0, len(numbers)):
total = total + numbers[ele]
print("Sum of all elements in given list: ", total)
OUTPUT:

Department of Computer Applications,BMSCE Page 18


22MCA1PCPY:Python Programming

Department of Computer Applications,BMSCE Page 19


22MCA1PCPY:Python Programming

21) Python program to find largest number in a list without using built in functions

numbers = []
n=int(input("Enter the range"))
for i in range(n):
j=int(input("Enter number "+str(i+1)+":"))
numbers.append(j)

largest = numbers[0]
for num in numbers[1:]:
if num > largest:
largest = num

print("The largest number in the list is:", largest)


OUTPUT

Department of Computer Applications,BMSCE Page20


22MCA1PCPY:Python Programming
22) Program to remove @gmail.com to @bmsce.ac.in in 10 email ids

emails = []
for i in range(10):
email = input("Enter email " + str(i+1) + ": ")
emails.append(email)

updated_emails = [email.replace("@gmail.com", "@bmsce.ac.in") for email in emails]

print(updated_emails)

OUTPUT

Department of Computer Applications,BMSCE Page 21


22MCA1PCPY:Python Programming
23) Python program to pick first letters as names and printing as names

name = input("Enter your name: ")


init=[]
let=name.split()
init=[word[0] for word in let]

for x in init:
print(x,end="")

OUTPUT

Department of Computer Applications,BMSCE Page 22


22MCA1PCPY:Python Programming
24) Develop a program to print the not-eligible student roll num and percentage
ofattendance by using dictionary Comprehensions

attendance = {'01':60,'02':76,'03':34,'08':77,'04':75,'05':80,'06':100}

not_eligible = {key: value for key, value in attendance.items() if value < 75}

result = {"Roll number " + str(key) + " has attendance percentage " + str(value) + "%" for
key, value in not_eligible.items()}

for item in result:


print(item)

OUTPUT:

Department of Computer Applications,BMSCE Page 23


22MCA1PCPY:Python Programming
25) Find the min and max score of a subject by using dictionary Comprehensions
Consider the following data
Marks = {'OS':[10,12,8,19] ,'python':[8,12,9,15,14] ,'DSA':[23,77,12,6,12]
,'MFCA':[8,9,12,17] ,'COA':[12,15,17,19] }

marks = {'OS': [10, 12, 8, 19], 'Python': [8, 12, 9, 15, 14], 'DSA': [23, 77, 12, 6, 12],
'MFCA': [8, 9, 12, 17], 'COA': [12, 15, 17, 19]}

min_scores = {subject: min(scores) for subject, scores in marks.items()}


max_scores = {subject: max(scores) for subject, scores in marks.items()}

print("Subject-wise minimum scores:")


for subject, score in min_scores.items():
print(f"{subject}: {score}")

print("Subject-wise maximum scores:")


for subject, score in max_scores.items():
print(f"{subject}: {score}")

OUTPUT:

Department of Computer Applications,BMSCE Page 24


22MCA1PCPY:Python Programming

26) Create a Python class called Bank Account which represents a bank
account, having as attributes: accountNumber (numeric type),
Name (name of the account owner as a string type), balance.
Create a constructor with the accountNumber, name, and balance
parameters.
Create a Deposit() method that manages the deposit actions.
Create a Withdrawal() method that manages withdrawal actions.
Create a bankFees () method to apply the bank fees with a percentage of 5%
of the balance account.
Create a display() method to display account details.

class BankAccount:
def init (self, accountNumber, name, balance):
self.accountNumber = accountNumber
self.name = name
self.balance = balance

def Deposit(self, amount):


self.balance += amount
print("Deposit successful. New balance is:", self.balance)

def Withdrawal(self, amount):


if self.balance < amount:
print("Insufficient funds. Cannot make the withdrawal.")

else:
print("Invalid amount. Please enter a valid amount.")

def bankFee(self):
fee = 0.05 * self.balance
self.balance -= fee
print("Bank fees of 5% applied. New balance is:", self.balance)

def display(self):
print("Account Details:")
print("Account Number:", self.accountNumber)
print("Account Holder Name:", self.name)
print("Account Balance:", self.balance)

Department of Computer Applications,BMSCE Page 25


22MCA1PCPY:Python Programming

account1 = BankAccount(123, "Sukruthi", 2000)


while True:
choice = input("Enter 'd' to deposit or 'w' to withdraw: ")
if choice == 'd':
amt = input("Enter the deposit amount: ")
account1.Deposit(float(amt))
account1.bankFee()
account1.display()

elif choice == 'w':


amt = input("Enter the withdrawal amount: ")
account1.Withdrawal(float(amt))
account1.bankFee()
account1.display()
else:
print("Invalid choice. Please enter 'd' or 'w'.")

OUTPUT:

Department of Computer Applications,BMSCE Page 26


22MCA1PCPY:Python Programming

27) Create a function that takes a number as an argument, increments


the number by +1 and returns the result.
def increment_number(num):
return num + 1
num = int(input("Enter the number"))
print("Number after incrementation")
increment_number(num)

OUTPUT:

28) Write a program to calculate the age of the user, by receiving the user's
DOB as input and using functions.

import datetime
def calculate_age(birthdate):
today = datetime.date.today()
age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month,
birthdate.day))
return age

birthdate_str = input("Enter your date of birth in YYYY-MM-DD format: ")


birthdate = datetime.datetime.strptime(birthdate_str, '%Y-%m-%d').date()

age = calculate_age(birthdate)
print("Your age is:", age)

Department of Computer Applications,BMSCE Page 27


22MCA1PCPY:Python Programming

OUTPUT:

29) Develop a program for conversion. CM to Inches (and vice versa),


Metersto Kilometers (and vice versa), Grams to Kilograms (and vice versa).
Initially, you need to collect input from the user by displaying the above
options for conversion procedures and perform accordingly.

def cm_to_inches(cm):
return cm / 2.54

def inches_to_cm(inches):
return inches * 2.54

def meters_to_kilometers(meters):
return meters / 1000

def kilometers_to_meters(kilometers):
return kilometers * 1000

def grams_to_kilograms(grams):
return grams / 1000

def kilograms_to_grams(kilograms):
return kilograms * 1000

print("1. CM to inches")
print("2. Inches to CM")
print("3. Meters to Kilometers")
print("4. Kilometers to Meters")
print("5. Grams to Kilograms")
print("6. Kilograms to Grams")

choice = int(input("Enter your choice: "))

if choice == 1:

Department of Computer Applications,BMSCE Page 28


22MCA1PCPY:Python Programming

cm = float(input("Enter length in CM: "))


inches = cm_to_inches(cm)
print(cm, "CM is equal to", inches, "inches.")
elif choice == 2:
inches = float(input("Enter length in inches: "))
cm = inches_to_cm(inches)
print(inches, "inches is equal to", cm, "CM.")
elif choice == 3:
meters = float(input("Enter length in meters: "))
kilometers = meters_to_kilometers(meters)
print(meters, "meters is equal to", kilometers, "kilometers.")
elif choice == 4:
kilometers = float(input("Enter length in kilometers: "))
meters = kilometers_to_meters(kilometers)
print(kilometers, "kilometers is equal to", meters, "meters.")
elif choice == 5:
grams = float(input("Enter weight in grams: "))
kilograms = grams_to_kilograms(grams)
print(grams, "grams is equal to", kilograms, "kilograms.")
elif choice == 6:
kilograms = float(input("Enter weight in kilograms: "))
grams = kilograms_to_grams(kilograms)
print(kilograms, "kilograms is equal to", grams, "grams.")
else:
print("Invalid choice. Please select a valid option.")

OUTPUT:

30) "A Bachelor of Engineering in Computer Science from BMS College


ofEngineering in Karnataka, 29-year-old Amrith was part of the

Department of Computer Applications,BMSCE Page 29


22MCA1PCPY:Python Programming

National Cadet Corps's Republic Day team in 2008 and harboured the
dream of being part of the marching contingents of one of the three services
at the celebrations in Delhi."

Apply all possible string handling operations to the above data. Identify the
length of the data, number of words, and print each word and how many
times it appeared in the data shared.

data = "A Bachelor of Engineering in Computer Science from BMS College of


Engineering in Karnataka, 29-year-old Amrith was part of the National Cadet
Corps's Republic Day team in 2008 and harboured the dream of being part of the
marching contingents of one of the three services at the celebrations in Delhi."
length = len(data)
print("Length of the data: ", length)
words = data.split()
num_words = len(words)
print("Number of words: ", num_words)
for word in words:
countnum = data.count(word)
print(word, ":", countnum)

OUTPUT:

Department of Computer Applications,BMSCE Page 30


22MCA1PCPY:Python Programming

Department of Computer Applications,BMSCE Page 31


31)

from google.colab import files


uploaded = files.upload()

Choose Files data.csv


data.csv(text/csv) - 213832 bytes, last modified: 5/2/2023 - 100% done
Saving data.csv to data.csv

import pandas as pd
pd.read_csv("data.csv")
df=pd.read_csv("data.csv")
df

1/16
work_year experience_level employment_type job_title salary salary_currency salary_in_usd

df.head(n=5) Principal
0 2023 SE FT Data 80000 EUR 85847
Scientist
work_year experience_level employment_type job_t tle salary salary_currency salary_in_usd emp
ML
1 2023 MI CT 30000 USD 30000
Prin ipal
Engineer
0 2023 SE FT Data 80000 EUR 85847
Sci ntist ML
2 2023 MI CT 25500 USD 25500
Engineer
ML
1 2023 MI CT 30000 USD 30000
Data
3 2023 SE FT Eng neer 175000 USD 175000
Scientist
ML
2 2023 MI CT 25500 USD 25500
Data
4 2023 SE FT Eng neer 120000 USD 120000
Scientist
Data
3 2023 SE FT 175000 USD 175000
... ... ... ... Sci ntist ... ... ... ...
DataData
3750
4 2020
2023 SE SE FT FT 120000
412000 USDUSD 120000
412000
Scientist
Scientist

Principal
3751 2021 MI FT Data 151000 USD 151000
Scientist

Data
3752 2020 EN FT 105000 USD 105000
df.tail(n=5) Scientist

Business
3753 work_year
2020 experience_level
EN employment_type
CT job_title
Data salary salary_currency
100000 USD salary_in_usd
100000
Analyst
Data
3750 2020 SE FT 412000 USD 412000
Scientist
Data
3754 2021 SE FT Science 7000000 INR 94665
Principal
Manager
3751 2021 MI FT Data 151000 USD 151000
3755 rows × 11 columns Scientist

Data
3752 2020 EN FT 105000 USD 105000
Scientist

Business
3753 2020 EN CT Data 100000 USD 100000
Analyst

Data
3754 2021 SE FT Science 7000000 INR 94665
Manager

df.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3755 entries, 0 to 3754
Data columns (total 11 columns):
# Column Non-Null Count Dtype

0 work_year 3755 non-null int64


1 experience_level 3755 non-null object
2 employment_type 3755 non-null object

2/16
3 job_title 3755 non-null object
4 salary 3755 non-null int64
5 salary_currency 3755 non-null object
6 salary_in_usd 3755 non-null int64
7 employee_residence 3755 non-null object
8 remote_ratio 3755 non-null int64
9 company_location 3755 non-null object
10 company_size 3755 non-null object
dtypes: int64(4), object(7)
memory usage: 322.8+ KB

df.sample(5)

work_year experience_level employment_type job_title salary salary_currency

Analytics
117 2023 SE FT 289800 USD
Engineer
Data
1846 2022 SE FT 51000 USD
Scientist
Data
519 2023 SE FT 275300 USD
Scientist
Data 106800
2076 2022 SE FT USD
Engineer
Data
759 2023 SE FT Operations 193000 USD
Engineer

df.describe()

work_year salary salary_in_usd remote_ratio

count 3755.000000 3.755000e+03 3755.000000 3755.000000

mean 2022.373635 1.906956e+05 137570.389880 46.271638

std 0.691448 6.716765e+05 63055.625278 48.589050

min 2020.000000 6.000000e+03 5132.000000 0.000000

25% 2022.000000 1.000000e+05 95000.000000 0.000000

50% 2022.000000 1.380000e+05 135000.000000 0.000000

75% 2023.000000 1.800000e+05 175000.000000 100.000000

max 2023.000000 3.040000e+07 450000.000000 100.000000

df.isnull()

3/16
work_year experience_level employment_type job_title salary salary_currency salary_in_usd

0 False False False False False False False

1 False False False False False False False

2 False False False False False False False

3 False False False False False False False

4 False False False False False False False

... ... ... ... ... ... ... ...

3750 False False False False False False False

3751 False False False False False False False

3752 False False False False False False False

3753 False False False False False False False

3754 False False False False False False False


df.loc[[3,5,6,12,18,19,29 ]]
3755 rows × 11 columns

work_year experience_level employment_type job_t tle salary salary_currency salary_in_usd em


Data
3 2023 SE FT 175000 USD 175000
Sci ntist

Ap lied
5 2023 SE FT 222200 USD 222200
Sc ntist

Ap lied
6 2023 SE FT 136000 USD 136000
Sc ntist

Data
12 2023 SE FT 100000 USD 100000
An lyst

Data
18 2023 SE FT 150000 USD 150000
Sci ntist

Data
19 2023 MI FT 150000 USD 150000
An lyst

Data
29 2023 SE FT 90000 USD 90000

df.iloc[2:8]

4/16
work_year experience_level employment_type job_title salary salary_currency salary_in_usd emp
ML
2 2023 MI CT 25500 USD 25500
Engineer

Data
3 2023 SE FT 175000 USD 175000
Scientist

Data
4 2023 SE FT 120000 USD 120000
Scientist
Applied
5
df.columns 2023 SE FT 222200 USD 222200
Scientist
Applied 'job_title',
Index(['work_year', 'experience_level', 'employment_type',
6 2023 SE FT 136000 USD 136000
'salary', 'salary_currency', 'salary_in_usd', 'employee_residence',
Scientist
'remote_ratio', 'company_location', 'company_size'],
dtype='object') Data
7 2023 SE FT 219000 USD 219000
Scientist

df.rename(columns={"job_title": "Company", "salary": "money"}).head()

work_year experience_level employment_type Comp ny money salary_currency salary_in_usd emplo

Princ pal
0 2023 SE FT Dta 80000 EUR 85847
Scie tist
ML
1 2023 MI CT 30000 USD 30000
Engi eer
ML
2 2023 MI CT 25500 USD 25500
Engi eer
D ta
3 2023 SE FT 175000 USD 175000
Scie tist
ta
4 2023 SE FT 120000 USD 120000
Scientist

df.drop(
labels=[5,7,12,18,27],
axis=0,
inplace=True
)
df

5/16
work_year experience_level employment_type job_t tle salary salary_currency salary_in_usd

Prin ipal
0 2023 SE FT Data 80000 EUR 85847
Scie tist

ML
1 2023 MI CT 30000 USD 30000
Engi eer

ML
2 2023 MI CT 25500 USD 25500
Engi eer

Data
3 2023 SE FT 175000 USD 175000
Scie tist

Data
4 2023 SE FT 120000 USD 120000
Scie tist

... ... ... ... ... ... ... ...

Data
3750 2020 SE FT 412000 USD 412000
Scie tist

Prin ipal
3751 2021 MI FT Data 151000 USD 151000
Scie tist

Data
3752 2020 EN FT 105000 USD 105000
Scientist
len(df) Business
3753 2020 EN CT Data 100000 USD 100000
3750 Analyst

Data
df.query("salary
3754 > salary_in_usd")
2021 SE FT Science 7000000 INR 94665
Manager

3750 rows × 11 columns

6/16
work_year experience_level employment_type job_title salary salary_currency salary_in_usd

Machine
41 2022 MI FT Learning 1650000 INR 20984
Engineer

Data
80 2023 MI FT 510000 HKD 65062
Scientist

Applied
156 2023 MI FT Data 1700000 INR 20670
Scientist
Data
217 2023 EN FT 1400000 INR 17022
df.sort_values(by="work_year")
Engineer

Applied
work_year experience_level employment_type job_t tle salary salary_currency salary_in_usd
218 2023 SE FT Data 100000 AUD 68318
Scientist
Staff Data
183 2020 EX FT 15000 USD 15000
An lyst
... ... ... ... ... ... ... ...
Data
3548 2020 EN FT Computer 10000 USD 10000
An lyst
3723 2021 SE FT Vision 102000 BRL 18907
Engineer
Ma hine
3549 2020 EN FT Lea ning
AI 138000 USD 138000
3729 2021 EN FT Eng neer 1335000 INR 18053
Scientist
Data
3681 2020 MI FT Lead Data 8000 USD 8000
3734 2021 MI FT An lyst 1450000 INR 19609
Analyst
Data
Data
3682
3746 2020
2021 EN
MI FT
FT 4450000
160000 JPY
SGD 41689
119059
Eng neer
Scientist
... ... ... ... ... ... ... ...
Data
3754 2021 SE FT Science
Data 7000000 INR 94665
1212 2023 SE FT Manager 170000 USD 170000
Eng neer

130 rows × 11 columns Data


1213 2023 SE FT 227000 USD 227000
An lyst

Data
1214 2023 SE FT 108000 USD 108000
An lyst

Data
1202 2023 SE FT Sci ntist 182200 USD 182200

Prin ipal
0 2023 SE FT Data 80000 EUR 85847
Scientist

3750 rows × 11 columns

df.replace('USD', 'IND')

7/16
work_year experience_level employment_type job_t tle salary salary_currency salary_in_usd

Prin ipal
0 2023 SE FT Data 80000 EUR 85847
Scie tist
ML
1 2023 MI CT 30000 IND 30000
Engi eer
ML
2 2023 MI CT 25500 IND 25500
Engi eer

Data
3 2023 SE FT 175000 IND 175000
Scie tist
Data
4 2023 SE FT 120000 IND 120000
Scie tist

... ... ... ... ... ... ... ...

Data
3750 2020 SE FT 412000 IND 412000
Scie tist

Prin ipal
3751 2021 MI FT Data 151000 IND 151000
Scie tist
Data
3752 2020 EN FT 105000 IND 105000
Scie tist
Busi ess
3753 2020 EN CT Data 100000 IND 100000
Analyst

Data
3754 2021 SE FT Science 7000000 INR 94665
Manager
df.groupby("job_title")['salary'].sum()
3750 rows × 11 columns

job_title
3D Computer Vision Researcher 480000
AI Developer 1509000
AI Programmer 110000
AI Scientist 4405000
Analytics Engineer 15589320
...
Research Engineer 6021854
Research Scientist 13183049
Software Data Engineer 150000
Staff Data Analyst 15000
Staff Data Scientist 105000
Name: salary, Length: 93, dtype: int64

df.count(0)

work_year 3750
experience_level 3750
employment_type 3750
job_title 3750
salary 3750
salary_currency 3750
salary_in_usd 3750
employee_residence 3750
remote_ratio 3750
company_location 3750

8/16
company_size 3750
dtype: int64

df.shape

(3750, 11)

df['salary'].mean()

190712.1792

df.select_dtypes(include='int64')

work_year salary salary_in_usd remote_ratio

0 2023 80000 85847 100

1 2023 30000 30000 100

2 2023 25500 25500 100

3 2023 175000 175000 100

4 2023 120000 120000 100

... ... ... ... ...

3750 2020 412000 412000 100

3751 2021 151000 151000 100

3752 2020 105000 105000 100

3753 2020 100000 100000 100

3754 2021 7000000 94665 50


3750 rows × 4 columns

from google.colab import files


uploaded = files.upload()

Choose Files industry.csv


industry.csv(text/csv) - 749 bytes, last modified: 5/3/2023 - 100% done
Saving industry.csv to industry.csv

pd.read_csv("industry.csv")
df1=pd.read_csv("industry.csv")
df1

9/16
Industry
0 Accounting/Finance

1 Advertising/Public Relations

2 Aerospace/Aviation

3 Arts/Entertainment/Publishing

4 Automotive

5 Banking/Mortgage

6 Business Development

7 Business Opportunity

8 Clerical/Administrative

9 Construction/Facilities

10 Consumer Goods

11 Customer Service

12 Education/Training

13 Energy/Utilities

14 Engineering

15 Government/Military

16 Green

17 Healthcare

18 Hospitality/Travel

19 Human Resources

20 Installation/Maintenance

21 Insurance

22 Internet

23 Job Search Aids

24 Law Enforcement/Security

25 Legal

26 Management/Executive

27 Manufacturing/Operations

28 Marketing

29 Non-Profit/Volunteer

30 Pharmaceutical/Biotech

31 Professional Services

32 QA/Quality Control

33 Real Estate

34 Restaurant/Food Service

10/16
35 Retail
df1.head(n=5)
36 Sales

37 Science/Research
Industry
38
0 Skilled Labor
Accounting/Finance
39 Technology
1 Advertising/Public Relations
40
2 Telecommunications
Aerospace/Aviation
41 Transportation/Logistics
3 Arts/Entertainment/Publishing
42 Other
4 Automotive

df1.tail(n=5)

Industry
38 Skilled Labor

39 Technology

40 Telecommunications

41 Transportation/Logistics

42 Other

df1.sample(5)

Industry
23 Job Search Aids

9 Construction/Facilities

4 Automotive

30 Pharmaceutical/Biotech

31 Professional Services

df1.columns

Index(['Industry'], dtype='object')

name=df1['Industry']
print(name)

0 Accounting/Finance
1 Advertising/Public Relations
2 Aerospace/Aviation
3 Arts/Entertainment/Publishing
4 Automotive
5 Banking/Mortgage
6 Business Development
7 Business Opportunity
8 Clerical/Administrative
9 Construction/Facilities
10 Consumer Goods

11/16
11 Customer Service
12 Education/Training
13 Energy/Utilities
14 Engineering
15 Government/Military
16 Green
17 Healthcare
18 Hospitality/Travel
19 Human Resources
20 Installation/Maintenance
21 Insurance
22 Internet
23 Job Search Aids
24 Law Enforcement/Security
25 Legal
26 Management/Executive
27 Manufacturing/Operations
28 Marketing
29 Non-Profit/Volunteer
30 Pharmaceutical/Biotech
31 Professional Services
32 QA/Quality Control
33 Real Estate
34 Restaurant/Food Service
35 Retail
36 Sales
37 Science/Research
38 Skilled Labor
39 Technology
40 Telecommunications
41 Transportation/Logistics
42 Other
Name: Industry, dtype: object

df1[3:10]

Industry
3 Arts/Entertainment/Publishing

4 Automotive

5 Banking/Mortgage

6 Business Development

7 Business Opportunity

8 Clerical/Administrative

9 Construction/Facilities

df1.loc[[2,4,6,7,8,9,19 ]]

12/16
Industry
2 Aerospace/Aviation

4 Automotive

df1.iloc[2:13]
6 Business Development

7 Business Opportunity
Industry
8 Clerical/Administrative
2 Aerospace/Aviation
9 Construction/Facilities
3 Arts/Entertainment/Publishing
19
4 Human Resources
Automotive

5 Banking/Mortgage

6 Business Development

7 Business Opportunity

8 Clerical/Administrative

9 Construction/Facilities

10 Consumer Goods

11 Customer Service

12 Education/Training

import numpy as np

df5 = pd.DataFrame([[
np.nan, 2, np.nan, 0],
[3, 4, np.nan, 1],
[np.nan, np.nan, np.nan, 5],
[np.nan, 3, np.nan, 4]],

)
print(df1)

Industry
0 Accounting/Finance
1 Advertising/Public Relations
2 Aerospace/Aviation
4 Automotive
5 Banking/Mortgage
6 Business Development
7 Business Opportunity
8 Clerical/Administrative
11 Customer Service
14 Engineering
15 Government/Military
16 Green
17 Healthcare
18 Hospitality/Travel
19 Human Resources
20 Installation/Maintenance
21 Insurance
22 Internet
23 Job Search Aids
24 Law Enforcement/Security
25 Legal

13/16
26 Management/Executive
27 Manufacturing/Operations
28 Marketing
29 Non-Profit/Volunteer
30 Pharmaceutical/Biotech
31 Professional Services
32 QA/Quality Control
33 Real Estate
34 Restaurant/Food Service
35 Retail
36 Sales
37 Science/Research
38 Skilled Labor
39 Technology
40 Telecommunications
41 Transportation/Logistics
42 Other

df1.fillna(0)

14/16
Industry
0 Accounting/Finance

1 Advertising/Public Relations

2 Aerospace/Aviation

4 Automotive

5 Banking/Mortgage

6 Business Development

7 Business Opportunity

8 Clerical/Administrative

11 Customer Service

14 Engineering

15 Government/Military

16 Green

17 Healthcare

18 Hospitality/Travel
df1.drop(
19 Human Resources
labels=[ 3,9,10,12,13],
axis=0,
20 Installation/Maintenance
inplace=True
) 21 Insurance
df1
22 Internet

23 Job Search Aids

24 Law Enforcement/Security

25 Legal

26 Management/Executive

27 Manufacturing/Operations

28 Marketing

29 Non-Profit/Volunteer

30 Pharmaceutical/Biotech

31 Professional Services

32 QA/Quality Control

33 Real Estate

34 Restaurant/Food Service

35 Retail

36 Sales

37 Science/Research

38 Skilled Labor

39 Technology

15/16
40 Telecommunications
Industry
41 Transportation/Logistics
0 Accounting/Finance
42 Other
1 Advertising/Public Relations

2 Aerospace/Aviation

4 Automotive

5 Banking/Mortgage

6 Business Development

7 Business Opportunity

8 Clerical/Administrative

11 Customer Service

14 Engineering

15 Government/Military

16 Green

17 Healthcare

18 Hospitality/Travel

19 Human Resources

20 Installation/Maintenance

21 Insurance

22 Internet

23 Job Search Aids

24 Law Enforcement/Security

25 Legal
26 Management/Executive

27 Manufacturing/Operations

28 Marketing

29 Non-Profit/Volunteer

30 Pharmaceutical/Biotech

31 Professional Services

32 QA/Quality Control

33 Real Estate

34 Restaurant/Food Service

35 Retail

36 Sales

37 Science/Research
38 Skilled Labor Colab paid products - Cancel contracts here0s
completed at 9:44 PM

16/16
22MCA1PCPY:Python Programming

32)
35) Consider the dataset, and perform the tasks defined below.

a) Read Total profit of all months and show it using a line plot
b) Read toothpaste sales data of each month and show it using a
scatter plot

Solution:
1. Using the data given below, develop scatter plot, line chart, bar
chart.

Solution:
2. Using python tkinter, design the following UI.
solution:

You might also like