0% found this document useful (0 votes)
2 views4 pages

My Python Programs

The document contains a series of Python programs that interact with users to answer questions about color mixing, calculate total costs and discounts based on the number of items bought, evaluate exam scores, and identify favorite animals. Each program includes conditional statements to provide feedback based on user input. The document also features a program to determine the largest of two numbers entered by the user.

Uploaded by

anju.ybis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

My Python Programs

The document contains a series of Python programs that interact with users to answer questions about color mixing, calculate total costs and discounts based on the number of items bought, evaluate exam scores, and identify favorite animals. Each program includes conditional statements to provide feedback based on user input. The document also features a program to determine the largest of two numbers entered by the user.

Uploaded by

anju.ybis
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

color = input("What color will you get when you mix red and yellow?

")

if(color=="orange"or color=="Orange"or color=="ORANGE"):

print("You are correct")

elif(color=="brown" or color=="Brown" or color=="BROWN"):

print("sorry that is red and green")

elif(color=="purple" or color=="Purple" or color=="PURPLE"):

print("Sorry that is red and blue")

else:

print("sorry that's incorrect")

cost1 = int(input("Enter the cost of one item"))

cost2 = int(input("Enter the cost of second item"))

total = cost1 + cost2

if(total >= 20):

print("The total cost is greater than or equal to 20")

else:

print("The total cost is less than 20")

totalCost = float(input("Enter the total cost"))

numberItems = int(input("Enter the number of items bought"))

if(numberItems >= 20 and numberItems<=29):

totalCost = totalCost * 0.9

print("After discount Total cost is", totalCost)

elif(numberItems>=30 and numberItems<=39):

totalCost = totalCost * 0.8

print("After discount Total cost is", totalCost)

elif(numberItems>=40 and numberItems<=49):

totalCost = totalCost * 0.7


print("After discount Total cost is", totalCost)

else:

print("no discount and the total cost is", totalCost)

[Link]

#Program to calculate the discount

totalCost = float(input("Enter the total cost"))

numberItems = int(input("Enter the number of items bought"))

if(numberItems >= 20 and numberItems<=29):

totalCost = totalCost * 0.9

print("After discount Total cost is", totalCost)

elif(numberItems>=30 and numberItems<=39):

totalCost = totalCost * 0.8

print("After discount Total cost is", totalCost)

elif(numberItems>=40 and numberItems<=49):

totalCost = totalCost * 0.7

print("After discount Total cost is", totalCost)

else:

print("no discount and the total cost is", totalCost)

#Program to calculate the discount

totalCost = float(input("Enter the total cost"))

numberItems = int(input("Enter the number of items bought"))

if(numberItems >= 20 and numberItems<=29):

totalCost = totalCost * 0.9

print("After discount Total cost is", totalCost)

elif(numberItems>=30 and numberItems<=39):

totalCost = totalCost * 0.8


print("After discount Total cost is", totalCost)

elif(numberItems>=40 and numberItems<=49):

totalCost = totalCost * 0.7

print("After discount Total cost is", totalCost)

elif(numberItems>=50):

totalCost = totalCost * 0.5

print("After discount Total cost is", totalCost)

else:

print("no discount and the total cost is", totalCost)

print("Thank you for shopping with us")

#Program to recognize color

color = input("What color is made when red and blue are mixed?")

if(color=="purple" or color=="Purple" or color=="PURPLE"):

print("Thats correct")

else:

print("Thats incorrect")

# Program to print the result

score = int(input("Enter your score"))

if(score>=50):

print("You Passed the exam")

else:

print("You failed and to pass you need more than 50")

print("Keep studying")

# Program to find out the favourite

userAnimal = input("What is my favourite animal?")

if (userAnimal == "horse" or userAnimal == "Horse" or userAnimal == "HORSE"):


print("Yes that's correct.")

else:

print("No, my favourite animal is a horse.")

print("Thank you for guessing")

#Program to find the largest number

first = int(input("Enter a number"))

second = int(input("Enter another number"))

if first > second:

print(first, "is the largest number input")

elif(first == second):

print("Both are equal")

else:

print(second, "is the largest number input")

You might also like