Premium Only Content

Conditionals - Advanced |Section 3|Celestial Warrior
In one of the previous exercises we created the following function:
def string_length(mystring):
return len(mystring)
Calling the function with a string as the value for the argument mystringwill return the length of that string.
However, if an integer is passed as an argument value:
string_length(10)
that wouldgenerate an error since the len() function doesn't work for integers.
Your duty is to modify the function so that if an integer is passed as an input, the function should output a message like "Sorry integers don't have length".
def string_length(mystring):
if type(mystring) == int:
return "Sorry, integers don't have length"
else:
return len(mystring)
The function that we implemented in the previous exercise checks integer datatypes, but not about floats. So, please expand the conditional block so that floats are counted too.
def string_length(mystring):
if type(mystring) == int:
return "Sorry, integers don't have length"
elif type(mystring) == float:
return "Sorry, floats don't have length"
else:
return len(mystring)
In one of the previous exercisesyou created a function that convertedCelsius degrees to Fahrenheit:
def cel_to_fahr(c):
f = c * 9/5 + 32
return f
Now, the lowest possibletemperature that physicalmatter can reach is -273.15C.With that in mind, please improve the function by making itprint out a message in case a number lower than -273.15 is passed as input when calling the function.
def c_to_f(c):
if c< -273.15:
return "That temperature doesn't make sense!"
else:
f=c*9/5+32
return f
print(c_to_f(-273.4))
-
1:09:33
TheCrucible
3 hours agoThe Extravaganza! EP: 36 (9/15/25)
131K9 -
1:13:06
Candace Show Podcast
2 hours agoThey Are Lying About Charlie Kirk. | Candace Ep 235
37.2K207 -
Kim Iversen
3 hours agoWas There a Second Shooter in the Charlie Kirk Attack?
25.7K37 -
DVR
Redacted News
3 hours ago“They’re NOT stopping with Charlie Kirk!” JD Vance TORCHES violent leftists | Redacted
206K77 -
39:45
Kimberly Guilfoyle
3 hours agoCharlie's Legacy and Our Mission | Ep.253
30.9K11 -
10:06
Tundra Tactical
3 hours agoWhats The Deal With New Guns In 2025 Part 2
5.96K -
1:13:10
The Amber May Show
4 hours ago $0.24 earnedCharlie Kirk Murder Probe EXPLODES | FBI, FEMA, & SCOTUS Shake the Nation
4.42K4 -
1:14:55
vivafrei
6 hours agoJD Vance Pays Tribute to Charlie Kirk; Ryan Routh Trial Continues! And More!
189K104 -
LIVE
Dr Disrespect
7 hours ago🔴LIVE - DR DISRESPECT - WARZONE - PROTECT THE DOC
911 watching -
LIVE
LFA TV
21 hours agoLFA TV ALL DAY STREAM - MONDAY 9/15/25
946 watching