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.
-
17:28
Neil McCoy-Ward
2 hours ago🚨 BREAKING! It’s Worse Than We Could Have Imagined! (What They Just Did Today Was Shocking!)
14.1K15 -
2:55:42
The Dana Show with Dana Loesch
3 hours agoEQUAL STANDARDS FOR MILITARY COMBAT | The Dana Show LIVE On Rumble!
17.6K2 -
58:58
The Tom Renz Show
2 hours agoElection Fraud, the GOP, & Corruption w/ Liz Harris
15.8K5 -
1:02:02
Timcast
3 hours agoGOP Office TORCHED By Terror Attack, Elon Says ARREST Democrat Billionaires Funding Attacks
186K235 -
1:54:09
Steven Crowder
5 hours agoSocial Security Scandal: How Elites Use Illegals to Game The American System
421K444 -
1:12:06
The Rubin Report
4 hours agoBill Maher Makes Gavin Newsom Look Dumb with Simple Questions
71K51 -
1:51:49
Benny Johnson
4 hours ago🚨 Trump CONFIRMS He Is Running For President AGAIN | Libs FREAK as Experts Say Third Term POSSIBLE
99.8K93 -
1:01:04
VINCE
6 hours agoWisconsin Decides The Future Of The World | Episode 11 - 03/31/25
322K277 -
52:12
Grant Stinchfield
3 hours ago $1.79 earnedTexas AG To Investigate Muslim Centric Communities and The Quest to Take Over America
25.8K9 -
33:56
Rethinking the Dollar
4 hours agoThe Bigger Issue Is War, Not A Silver Squeeze | Morning Check-In
36.9K8