Write code that iterates through the given list "scores" and checks which letter grade each score has earned. In response, it should add the corresponding letter grade to the empty list "grades", according to the table below.
The square and round brackets denote closed and open intervals. A closed interval includes the number, and open interval excludes it. So 79.99999 gets grade C , but 80 gets grade B.
A year is a leap year if it is divisible by 4; however, if the year can be evenly divided by 100, it is NOT a leap year, unless the year is also evenly divisible by 400 then it is a leap year. Write code that iterates through the given list of years and adds leap years to a list of booleans called "is_leap_year". Use if statements.
Give the logical opposites of these conditions, meaning an expression that would produce False whenever this expression produces True, and vice versa. You are not allowed to use the not operator.
Provided are the lengths of two sides of a right-angled triangle. Assign the length of the hypotenuse the the variable hypo_len. (Hint: x ** 0.5 will return the square root, or use sqrt from the math module)
Provided is a list of numbers. For each of the numbers in the list, determine whether they are even. If the number is even, add True to a new list called is_even. If the number is odd, then add False.
Provided is a list of numbers. For each of the numbers in the list, determine whether they are odd. If the number is odd, add True to a new list called is_odd. If the number is even, then add False.
Given the lengths of three sides of a triange, determine whether the triangle is right angled. If it is, the assign True to the variable is_rightangled. If itβs not, then assign False to the variable is_rightangled.
Hint: floating point arithmetic is not always exactly accurate, so it is not safe to test floating point numbers for equality. If a good programmer wants to know whether x is equal or close enough to y, they would probably code it up as
Special note: The algorithm can give a date in April. You will know that the date is in April if the calculation gives you an answer greater than 31. (Youβll need to adjust) Also, if the year is one of four special years (1954, 1981, 2049, or 2076) then subtract 7 from the date.
Get the user to enter some text and print out True if itβs a palindrome, False otherwise. (Hint: Start by reversing the input string, and then use the == operator to compare two values to see if they are the same)
Write a program that will print out a greeting to each student in the list. This list should also keep track of how many students have been greeted and note that each time a new student has been greeted. When only one student has entered, the program should say βThe first student has entered!β. Afterwards, the program should say βThere are {number here} students in the classroom!β.