Open utterances-bot opened 1 year ago
is_citizen = input("Are you a citizen? (yes/no): ").strip().lower() age = int(input("Enter your age: "))
if is_citizen == "yes" and age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter your years of service: "))
if years_of_service > 5: bonus = 0.05 * salary print(f"You are eligible for a bonus of ${bonus:.2f}") else: print("You are not eligible for a bonus.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
citizen = False age = 24 if citizen and age >=18:# if both conditions are met print("you are eligible to vote") else: print("You are not eligible to vote")#if either condition isnt met
salary = int(input())#user input years = int(input())#user input if years >= 5:#checks if service is above 5 years salary = salary*1.05 #adds 5% bonus print("Your salary is now", salary) else: print("no bonus")
grade = int(input()) if grade<25: print("F") if 25<=grade<45: print("E") if 45<=grade<50: print("D") if 50<=grade<60: print("C") if 60<=grade<80: print("B") if grade>=80: print("A")
n = int(input("enter age: "))
if n >= 18:
print("You are eligible to vote!")
else:
print("You are NOT eligible to vote!")
salary = int(input("salary? ")) years = int(input("You many years of service? "))
if years > 5: print("total bonus: "+str(salary*1.05)) else: print("no bonus lol")
n = int(input("Enter grade: ")) if n < 25: print("F") if 45 > n >= 25: print("E") if 50 > n >= 45: print("D") if 60 > n >= 50: print("C") if 80 > n >= 60: print("B") if n >= 80: print("A")
ignore ^^ real submission: https://alishahussain.github.io/student2//2023/10/11/boolean_conditionals_IPYNB_2_.html
citizen_status = input("Are you a citizen? (yes/no): ").lower() age = int(input("Enter your age: "))
is_citizen = citizen_status == "yes" is_18_or_older = age >= 18
is_eligible_to_vote = is_citizen and is_18_or_older
if is_eligible_to_vote: print("You are eligible to vote. Go ahead and cast your vote!") else: print("Sorry, you are not eligible to vote. Please wait until you meet the criteria.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter your years of service: "))
is_eligible_for_bonus = years_of_service > 5
if is_eligible_for_bonus: bonus_percentage = 5 bonus_amount = (bonus_percentage / 100) * salary print(f"Congratulations! You are eligible for a {bonus_percentage}% bonus.") print(f"Net bonus amount: ${bonus_amount:.2f}") else: print("Sorry, you are not eligible for a bonus at this time.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
citizen = input("Are you a US citizen? (yes/no)")
if citizen == "yes": age = int(input("what is your age")) if age >= 18:
print("you are eligible to vote!")
else:
#if not, they can't vote
print("sorry, you are too young to vote. maybe wait a few years!")
else:
print("sorry, you are not eligible to vote")
current_salary=float(input("Type your salary")) years=int(input("Type the amount of years you have serviced the company")) if(years>5): print(current_salary*1.05, "is your new salary") else: print(current_salary, "is your salary")
marks = float(input("What are your marks?"))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print("Your grade is a(n)", grade)
age = 16 if (age >= 18) == True: print("You can vote") else: print("You cannot drive")
yearsInCompany = int(input("How long have you been with the company?: ")) salary = int(input("Enter your salary: ")) bonus = 0 if yearsInCompany >= 5: bonus = (int(salary) * 1.05) - salary print("Your bonus is " + "$" + str(bonus)) else: print("Sorry, no bonus.")
grade = int(input("Enter your grade")) if grade > 80: letterGrade = "A" elif grade > 60: letterGrade = "B" elif grade > 50: letterGrade = "C" elif grade > 45: letterGrade = "D" elif grade > 25: letterGrade = "E" else: letterGrade = "F" print(letterGrade)
def votecheck(age): if age >= 18:
print("You are eligible to vote.")
else:
# If you are younger than 18, then you are not eligible to vote.
print("You are not eligible to vote.")
age = input("Please enter your age: ") age = int(age) votecheck(age)
def bonuscheck(salary, years): if years > 5:
bonus = salary * 0.05
print("Net Bonus:", bonus, "dollars")
else:
# If the person has been at the company for less than 5 years, there is no bonus.
print("Net Bonus: 0 dollars")
years = input("How many years have you been in the company: ") years = float(years) salary = input("What is your annual salary: ") salary = float(salary) bonuscheck(salary, years)
def gradecheck(score):
if score < 25:
print("F")
elif score >= 25 and score < 45:
print("E")
elif score >= 45 and score < 50:
print("D")
elif score >= 50 and score < 60:
print("C")
elif score >= 60 and score < 80:
print("B")
elif score >= 80:
print("A")
score = input("Please enter your score: ") score = float(score) gradecheck(score)
age = int(input("Enter your age: "))
if age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter your years of service: "))
if years_of_service > 5: bonus = 0.05 * salary print(f"Your bonus amount is ${bonus:.2f}") else: print("You are not eligible for a bonus.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
The comment didnt go through for some reason: https://tanuj253.github.io/student/5.a/c4.1/2023/10/10/boolean-expression-and-conditions_IPYNB_2_.html
user = int(input()) #user input as integer (age)
if user >= 18: #>= checks if they are older than or equal to 18
print("vote eligible")
else: #otherwise
print("user is unable to vote")t
import datetime
today = datetime.date.today()
year = int(today.year)
salary = int(input("What is your salary"))
servyear = int(input("What year did you start"))
if year - servyear > 5:
salary = salary + (salary * .05)
print(salary)
grade = int(input("enter your grades"))
def detGrade():
if grade < 25:
return "F"
if grade < 45:
return "E"
if grade < 50:
return "D"
if grade < 60:
return "C"
if grade < 80:
return "B"
if grade > 80:
return "A"
print(detGrade())
1.
is_citizen = input("Are you a citizen? (yes/no): ").strip().lower() == "yes" age = int(input("Enter your age: "))
if is_citizen and age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.") 2. salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter the number of years in service: "))
if years_of_service > 5: bonus = 0.05 * salary # 5% bonus print(f"Your bonus amount is: ${bonus:.2f}") else: print("You are not eligible for a bonus.") 3. marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
is_citizen = input("Are you a citizen? (yes/no): ").strip().lower() == "yes" age = int(input("Enter your age: "))
if is_citizen and age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter the number of years in service: "))
if years_of_service > 5: bonus = 0.05 * salary # 5% bonus print(f"Your bonus amount is: ${bonus:.2f}") else: print("You are not eligible for a bonus.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
# Silly thing I made that made me Mad!
print("Welcome to MegaCorp, please state your details")
userFirstName = input("First Name: ")
print("Input 'Null' if you don't have a prefered Name ")
userPreferedName = input("Prefered Name: ")
userLastName = input("Last Name: ")
userAge = input("Age: ")
# What I used to bypass login, comment everything above and uncomment the comments below except for this line
# userAge = 20
# userFirstName = "Fred"
# userPreferedName = "Freddy"
# userLastName = "Kilm"
# userPay = 0
def findPercent(userInput):
currentUserGrade = ""
currentUserClass = ""
classes = ["A", "B", "C", "D", "E", "F", "G"]
for x in userInput:
print(x)
if(x.isdigit()):
currentUserGrade += x
continue
for y in classes:
if x.upper() == y:
currentUserClass = y
continue
currentUserGrade = int(currentUserGrade)
return currentUserClass, currentUserGrade
def MegaCorpFinance():
global userPreferedName, userPay
yearsOfEmployee = input(f"How many years have you served at the company {userPreferedName}? ")
jobPay = { # Per year
"Coder": 150000,
"Janitor": 30000
}
for jobTitle in jobPay:
print("\t*" + str(jobTitle))
employeeTitle = input("Out of these, which is your job? ")
for jobTitle in jobPay:
if(employeeTitle.upper() == jobTitle.upper()):
print("Valid Title")
employeeTitle = jobTitle
if(userPay == 0):
userPay = jobPay[str(employeeTitle)]
if(int(yearsOfEmployee) > 5):
userPay *= 1.05
print(userPay)
if(userPreferedName.upper() == "NULL"):
userPreferedName = userFirstName
else:
userPreferedName = userPreferedName
if(int(userAge) > 18):
print("Redirecting you to MegaCorpMain")
MegaCorpFinance()
elif(int(userAge) < 18):
print(f"{userPreferedName}, we are redirecting you to MegaCollegeCorp")
print("\tType: A + grade for your last History")
print("\tType: B + grade for your last English")
print("\tType: C + grade for your last Math")
print("\tType: D + grade for your last Science")
print("\tType: E + grade for your last Forign Language")
print("\tType: F + grade for your last Fine Arts")
print("\tType: G + grade for your last Electives")
print("\tType Submit to submit your grades to us")
userGrade = {
"A": "A", # History
"B": "A", # English
"C": "A", # Math
"D": "A", # Science
"E": "A", # Forign Language
"F": "A", # Fine Arts
"G": "A" # Electives
}
while 7 == 7:
userInput = input("Input percents from your classes in base 10: ")
userInput = userInput.replace(" ", "")
print("User input is: " + str(userInput))
classes = ["A", "B", "C", "D", "E", "F", "G"]
grades = ["A", "B", "C", "D", "E", "F"]
if(userInput.upper() == "SUBMIT"):
jobRequirements = {
"Coder": {
"A": "C",
"B": "B",
"C": "A",
"D": "A",
"E": "C",
"F": "C",
"G": "C"
},
"Jainitor": {
"A": "D",
"B": "D",
"C": "D",
"D": "D",
"E": "D",
"F": "D",
"G": "D"
}
}
for currentJob in jobRequirements:
amountOfRequirements = 0
print(f"Scanning Requirement for {currentJob}")
for currentClassCheck in classes:
if(grades.index(jobRequiremets[currentJob][currentClassCheck]) >= grades.index(userGrade[currentClassCheck])):
amountOfRequirements += 1
if(amountOfRequirements > 4):
print(f"You got the application for {currentJob}!")
break
break
percent = findPercent(userInput)
currentUserGrade = int(percent[1])
currentUserClass = percent[0]
if(currentUserGrade > 80):
currentUserGrade = "A"
elif(currentUserGrade >= 60):
currentUserGrade = "B"
elif(currentUserGrade >= 50):
currentUserGrade = "C"
elif(currentUserGrade >= 45):
currentUserGrade = "D"
elif(currentUserGrade >= 25):
currentUserGrade = "E"
else:
currentUserGrade = "F"
userGrade[str(currentUserClass)] = currentUserGrade
print(f"Class type {currentUserClass} is now set to grade {currentUserGrade}")
Get user input for citizenship status and age citizen_status = input("Are you a citizen? (yes/no): ").lower() age = int(input("Enter your age: "))
Check if the user is a citizen and 18 or older is_citizen = citizen_status == "yes" is_18_or_older = age >= 18
Use boolean logic to determine eligibility is_eligible_to_vote = is_citizen and is_18_or_older
Display the result if is_eligible_to_vote: print("You are eligible to vote. Go ahead and cast your vote!") else: print("Sorry, you are not eligible to vote. Please wait until you meet the criteria.")
Get user input for salary and years of service salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter your years of service: "))
Check if the employee is eligible for a bonus (more than 5 years of service) is_eligible_for_bonus = years_of_service > 5
Calculate the bonus amount (5% of salary) if eligible if is_eligible_for_bonus: bonus_percentage = 5 bonus_amount = (bonus_percentage / 100) * salary print(f"Congratulations! You are eligible for a {bonus_percentage}% bonus.") print(f"Net bonus amount: ${bonus_amount:.2f}") else: print("Sorry, you are not eligible for a bonus at this time.")
Get user input for marks marks = float(input("Enter your marks: "))
Determine the grade based on the given rules if marks < 25: grade = "F" elif 25 <= marks < 45: grade = "E" elif 45 <= marks < 50: grade = "D" elif 50 <= marks < 60: grade = "C" elif 60 <= marks < 80: grade = "B" else: grade = "A"
Display the corresponding grade print(f"Your grade is: {grade}")
Mistake with my code, the default for the ‘userGrade‘ should be “F” for all of them not “A”, this came about because it was easier to test than manually editing all of them every time I changed something. Please when executing change this mistake to: userGrade = { “A” : “F”, “B” : “F”, “C” : “F”, “D” : “F”, “E” : “F”, “F” : “F”, “G” : “F” }
# Assume the voter's age and citizenship status
age = 18 # Adjust this value to the voter's age
is_citizen = True # Set to True if the voter is a citizen, or False if not
# Determine voter eligibility
eligible_to_vote = age >= 18 and is_citizen
# Check if the voter is eligible and provide feedback
if eligible_to_vote:
print("You are eligible to vote in the election.")
else:
print("You are not eligible to vote in the election.")
# Get user input for salary and years of service
salary = float(input("Enter your salary: $"))
years_of_service = int(input("Enter your years of service: "))
# Check if the employee is eligible for a bonus
if years_of_service > 5:
bonus_percentage = 5 # 5% bonus for more than 5 years of service
bonus_amount = (bonus_percentage / 100) * salary
print(f"You are eligible for a {bonus_percentage}% bonus.")
print(f"Net bonus amount: ${bonus_amount:.2f}")
else:
print("You are not eligible for a bonus.")
student_score = 0
if student_score < 25:
student_grade = "F"
elif 25 <= student_score <= 45:
student_grade = "E"
elif 45 < student_score <= 50:
student_grade = "D"
elif 50 < student_score <= 60:
student_grade = "C"
elif 60 < student_score <= 80:
student_grade = "B"
else:
student_grade = "A"
print(student_grade)
Q1: is_citizen = input("Are you a citizen? (yes/no): ").lower() == "yes" age = int(input("Enter your age: ")) print("You are eligible to vote." if is_citizen and age >= 18 else "You are not eligible to vote.")
Q2: salary = float(input("Enter your salary: $")) years_of_service = int(input("Enter your years of service: ")) bonus = 0.05 * salary if years_of_service > 5 else 0 print(f"Your net bonus amount is: ${bonus:.2f}")
Q3: marks = float(input("Enter your marks: ")) grade = ( "A" if marks > 80 else "B" if marks >= 60 else "C" if marks >= 50 else "D" if marks >= 45 else "E" if marks >= 25 else "F" ) print(f"Your grade is: {grade}")
is_citizen = input("Are you a citizen (yes/no)? ").lower() # Convert the input to lowercase for case-insensitivity age = int(input("Enter your age: "))
if is_citizen == "yes" and age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter the number of years of service: "))
if years_of_service > 5: bonus = 0.05 * salary print(f"Your bonus amount is ${bonus:.2f}") else: print("You are not eligible for a bonus.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif marks < 45: grade = "E" elif marks < 50: grade = "D" elif marks < 60: grade = "C" elif marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
is_citizen = input("Are you a citizen (yes/no)? ").lower() # Convert the input to lowercase for case-insensitivity age = int(input("Enter your age: "))
if is_citizen == "yes" and age >= 18: print("You are eligible to vote.") else: print("You are not eligible to vote.")
salary = float(input("Enter your salary: ")) years_of_service = int(input("Enter the number of years of service: "))
if years_of_service > 5: bonus = 0.05 * salary print(f"Your bonus amount is ${bonus:.2f}") else: print("You are not eligible for a bonus.")
marks = float(input("Enter your marks: "))
if marks < 25: grade = "F" elif marks < 45: grade = "E" elif marks < 50: grade = "D" elif marks < 60: grade = "C" elif marks < 80: grade = "B" else: grade = "A"
print(f"Your grade is: {grade}")
P1 booleans and conditions | Compci Blogs
3.5 Boolean Expressions and 3.6 Conditionals
https://nighthawkcoders.github.io/teacher/2023/10/09/P1_Booleans_IPYNB2.html