Skip to content

Instantly share code, notes, and snippets.

@chauhan-tarun
Created March 25, 2018 10:17
Show Gist options
  • Save chauhan-tarun/9f71680addf11065b30244babdf1a99a to your computer and use it in GitHub Desktop.
Save chauhan-tarun/9f71680addf11065b30244babdf1a99a to your computer and use it in GitHub Desktop.
Exercise answers of video tutorial "Python 3 for beginners - #5.Conditions" by TheTechnicalFist : https://youtu.be/Lmrpdmk9Hxo
# #########################################################
# Question 1.
# Get two number from user
input1 = eval(input("Enter number 1 : "))
input2 = eval(input("Enter number 2 : "))
# Check which number is greater
if input1 > input2:
print(input1, " is greater.")
elif input1 < input2:
print(input2, " is greater.")
else:
print("Both inputs are equal.")
# #########################################################
# Question 2.
# Get the input from user
char = input("Enter a character : ")
if char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u':
print("Inputted character is a vowel")
else:
print("Inputted character is a consonant")
# #########################################################
# Question 3.
# Get Inputs
age = eval(input("Enter your age : "))
foundAnyGirl = eval(input("Did you found any girl for marriage? : [1/0]"))
# Check All conditions
if age < 21:
print("Not eligible for marriage. No need to find anyone either. Just study :P")
elif 21 <= age <= 40 and foundAnyGirl:
print("Let's get married.")
elif 21 <= age <= 40 and not foundAnyGirl:
print("Find a girl quickly. Because you may die single if you cross 40")
elif age > 40 and foundAnyGirl:
print("You are really lucky because it’s really difficult to get someone at this age. Hurry up and get married "
"before she leaves you and you die Single :P")
else:
print("No need to find anyone... You will die single :P :(")
# #########################################################
# Question 4.
print("Marks are counted out of 100.")
# Get marks
english = eval(input("Enter marks in english : "))
maths = eval(input("Enter marks in maths : "))
business = eval(input("Enter marks in Business : "))
accounts = eval(input("Enter marks in Accounts : "))
economics = eval(input("Enter marks in Economics : "))
# Find total marks obtained
totalMarks = english + maths + business + accounts + economics
# Find percentage
totalPercent = totalMarks / 500 * 100
# Print total percentage
print("You've got ", totalPercent, "%")
# Check grade
if totalPercent > 90:
print("Grade : A")
elif totalPercent > 80:
print("Grade : B")
elif totalPercent > 70:
print("Grade : C")
elif totalPercent > 60:
print("Grade : D")
elif totalPercent > 50:
print("Grade : E")
else:
print("Sorry you are failed. Better luck next time ;)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment