Premium Only Content

Functions and User Input |Section 3|Celestial Warrior
The next lecture will be an exercise and there will be more exercises as you progress through the course.
The exercises are difficult and sometimes tricky and I don't expect students to solve them all. Most students actually fail to solve the exercisesunless they are already familiar with Python.
The whole point of exercises is to force you to think about how to solve a problem independently. The next lecture following each exercise contains the solution where you can compare your approach.
Create a functionthat converts Celsius degrees toFahrenheit. The formula to convert Celsius to Fahrenheit isF= C 9/5 + 32.
In the previous exercises you used the interactive Udemy interface to write your code.For this exercise, please use your computertools (Python, editor, terminal,etc.). This will help you get used with Python in a real environment.
Once you are done check your solution against my solution which islocatedin the next lecture. Don't worry if your solution is not exactly the same as mine. As far as the solutions generate the same output, your solution is most likely correct.
def cel_to_fahr(c):
f = c * 9/5 + 32
return f
And here is an example of calling the function:
print(cel_to_fahr(10))
That would return 50.0 which means 10 degreeCelsius is equal to 50 degreeFahrenheit.
Create a function that takes any string as argument and returns the length of that string.
def string_length(mystring):
return len(mystring)
And here's an example of calling the function:
print(string_length("Hello"))
That would return 5.
-
1:20:26
Kim Iversen
4 hours agoThis Intel Analyst Has Accurately Predicted Putin's Every Move... Is War With NATO Next?
98.7K31 -
LIVE
SpartakusLIVE
1 hour ago#1 HERO of the PEOPLE || Ending the Week with FUN, WINS, and LAUGHS
124 watching -
LIVE
GritsGG
11 hours agoQuad Win Streaks!🫡 Most Wins in WORLD! 3600+
111 watching -
2:34:12
Spartan
4 hours agoScrims vs Mindfreak and then Ranked or another game idk
20K1 -
1:35:57
Roseanne Barr
6 hours agoEnd-Time Prophecies REVEALED: Jonathan Cahn’s Warning
155K58 -
1:08:58
vivafrei
7 hours agoComey INDICTED! Proof Jan. 6 was a FED-SURRECTION! Ostrich Crisis Getting More Attention & MORE!
162K102 -
LIVE
StevieTLIVE
2 hours agoBirthday Bash HYPE Warzone Wins ALL NIGHT
16 watching -
6:30:53
Dr Disrespect
9 hours ago🔴LIVE - DR DISRESPECT - ARENA BREAKOUT: INFINITE - STORM EVENT
186K9 -
3:35:23
Barry Cunningham
9 hours agoPRESIDENT TRUMP SPEAKS ON JAMES COMEY INDICTMENT! MORE TO COME! DELICIOUS LIBERAL MELTDOWNS!
83.7K46 -
25:59
Simply Bitcoin
1 day ago $2.42 earnedMichael Saylor Reveals $81T Bitcoin Plan to Cancel National Debt?!
46K9