Python Module 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Python_Module_1

Conditional statement
Question-1

You are tasked with writing a Python program to identify an employee whose
projected income falls between 10 LPA and 12 LPA (both values inclusive).
Below is a guide to assist you in writing the code:

if (Salary >=10 and Salary <=12):

print("Great! You are selected")

else:

print("Apologies! We can’t move on with your application")


Question-2
You are tasked with creating a program to assess whether an employee
possesses the necessary programming language skills for a specific job
role.

print("The language you selected is:",Language)

if (Language=="Python" or Language=="Java"):

print("Great! You are selected")

else:

print("Apologies! We can’t move on with your application")


Question-3
You're required to develop a program that determines whether a candidate
is eligible for a job based on specific criteria. The candidate's age,
experience, programming language skills, and expected salary will be
considered.

if(Age > 23):

print("Age Criteria: Pass")

else:

print("Age Criteria: Fail")

if(Experience > 5):

print("Experience Criteria: Pass")


else:

print("Experience Criteria: Fail")

if(Language == "Python" or Language == "Java"):

print("Language Criteria: Pass")

else:

print("Language Criteria: Fail")

if(Salary >= 10 and Salary <= 12):

print("Salary Criteria: Pass")

else:

print("Salary Criteria: Fail")


Question-4
The company policy mandates that each employee must have an ID card. You
need to develop a simple Python code to determine whether an employee has
an ID card or not.

if(IDCard==True):

print("Welcome! Have a great day ahead")

else:

print("Access Denied!!")

CONDITIONAL LADDER
Question-1
You're presented with a task to determine the bonus percentage for
employees based on their performance grade.

if(Grade=="A" or Grade=="a"):

print("You will receive bonus of 125%")

elif(Grade=="B" or Grade=="b"):

print("You will receive bonus of 100%")

elif(Grade=="C" or Grade=="c"):
print("You will receive bonus of 75%")

elif(Grade=="D" or Grade=="d"):

print("You will receive bonus of 50%")

elif(Grade=="E" or Grade=="e"):

print("Apologies! You will receive no bonus")

else:

print("Invalid input")
Question-2
Use the following conditions to determine the tier and the corresponding
benefit message:
1. If the experience is between 0 and 2 (inclusive), print "You will
receive Tier 1 Benefits :)".
2. If the experience is between 3 and 5 (inclusive), print "You will
receiveTier 2 Benefits :)".
3. If the experience is between 6 and 8 (inclusive), print "You will
receive Tier 3 Benefits :)".
4. If the experience is 9 or more, print "You will receive Tier 4
Benefits".
5. For any other input, print "Invalid Input".
if(Experience >=0 and Experience <=2):
print("You will receive Tier 1 Benefits :)")
elif(Experience >=3 and Experience <=5):
print("You will receiveTier 2 Benefits :)")
elif(Experience >=6 and Experience <=8):
print("You will receive Tier 3 Benefits :)")
elif(Experience >= 9):
print("You will receive Tier 4 Benefits")
else:
print("Invalid Input")

LOOP
Question-1
Your task is to create a Python program that takes the salaries of three
new employees and adds these costs to the existing expense amount of
102000. The program should then display the final expense total.

num_employees = 3
total_expenses = 102000

for employee in range(1,num_employees + 1):

total_expenses +=salary

print("The total salary expenses for ",num_employees," employees is: ", total_expenses)
Question-2
In your role as the HR manager, you are responsible for evaluating
employee ratings and deciding appropriate actions based on their
performance. You have received employee rating data in the form of a
matrix. You need to create a program that checks each employee's rating
and determines the next steps accordingly.

for i in range(1,N+1):

if rating >= 4.0:

print("Sending information to EMP", i,employee_name, "is performing well. No action needed.")

elif rating >= 3.0 and rating<4:

print("Sending information to EMP", i,employee_name," has average performance. Consider


improvement plan.")

else:

print("Sending information to EMP", i,employee_name," is underperforming. Consider


termination.")

LOOP+CONDITION
Question-1
As the corporate landscape continues to evolve, technological advancements
have led to the dominance of machines and automation. In light of this,
your company requires an attendance system to efficiently manage employee
presence. Your task involves creating a temporary attendance system that
can accurately track employee attendance, and provide insights such as the
total attendance count, the number of employees on holiday, and the number
of absent employees.

N=3

Pcount = 0

Hcount = 0

for i in range(N):

attendance = attendance_data[i]

if attendance == "P":
Pcount += 1

elif attendance == "H":

Hcount += 1

print("Total employees:", N)

print("Total attendance for employees:", Pcount)

print("Total number of employees on holiday:", Hcount)

print("Total number of absent employees:", N - Pcount - Hcount)


Question-2
We need to update the appraisal code which we have created previously. The
company decided to have 3 reviewers in place who will rate each employee
and then the average rating will be used to assign the bonus to each
employee. So the three inputs will be taken from TeamLead, Manager, and
CEO. you need to take all the review ratings and take out the average by
using the arithmetic operator and then check with all the conditions.

N=2

employee_data = [

{"name": "Omkar", "TL_rating": 3.9, "Manager_rating": 4.5, "CEO_rating": 3.8},

{"name": "Bhavana", "TL_rating": 4.2, "Manager_rating": 4.2, "CEO_rating": 3.7}

for i in range(N):

employee = employee_data[i]

name = employee["name"]

TLrating = employee["TL_rating"]

Mrating = employee["Manager_rating"]

CEOrating = employee["CEO_rating"]

Frating = (TLrating + Mrating + CEOrating) / 3

print(name,"Your Rating:",Frating)

if Frating >= 0 and Frating <=2:

print("You will receive a bonus of 10%")

elif Frating >= 2 and Frating <=3:


print("You will receive a bonus of 25%")

elif Frating >= 3 and Frating <=4:

print("You will receive a bonus of 50%")

elif Frating >= 4 and Frating <=4.8:

print("You will receive a bonus of 75%")

elif Frating > 4.9:

print("You will recieve a bonus of 125%")

else:

print("Invalid Input")

1.1 CAPSTONE PROJECT


Question-1
Write a Python code snippet to create the following pattern given in the

expected output using for loop .

for i in range(rows):

spaces = " " * (rows - i - 1)

stars = "*" * (2 * i + 1)

print(spaces + stars)
Question-2
Write a code to implement the logic and print the following pattern given

below using for loop .

for i in range(rows -2 ,-1, -1):

spaces = " " * (rows - i - 1)

stars = "*" * (2 * i + 1)

print(spaces + stars)
Question -3
Write a code to implement the logic and print the following pattern given

below .

for i in range(rows):

spaces = " " * (rows - i - 1)

stars = "*" * (2 * i + 1)

print(spaces + stars)

for i in range(rows -2 ,-1, -1):

spaces = " " * (rows - i - 1)

stars = "*" * (2 * i + 1)

print(spaces + stars)

Question-4
Write a Python program that checks a student's grade based on their
percentage according to the given criteria table:

if Percentage >= 85:

print("O")

elif Percentage >= 75 and Percentage < 85:

print("A")

elif Percentage >= 65 and Percentage < 75:

print("B")

elif Percentage >= 50 and Percentage < 65:

print("C")

elif Percentage >= 35 and Percentage < 50:

print("D")

else:

print("Sorry! You didn't pass the exam. Try next time")

You might also like