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.
-
LIVE
Major League Fishing
5 days agoLIVE! - Fishing Clash Team Series: Heritage Cup - Day 2
428 watching -
1:08:54
Simply Bitcoin
3 hours ago $0.46 earnedNEW REPORT SUGGESTS THE BITCOIN SUPPLY SHOCK IS ACCELERATING?! | EP 1332
8.08K -
10:31
Dr. Eric Berg
3 hours ago13 Foods You Should Never Buy Organic
56.7K19 -
15:10
SB Mowing
1 month agoShe had TEARS OF JOY on her face - An update on Beth
44K33 -
LIVE
Lofi Girl
3 years agolofi hip hop radio 📚 - beats to relax/study to
325 watching -
2:15:26
Nikko Ortiz
3 hours agoLIVE - Farm Animals Attack!
209K7 -
9:30
Sugar Spun Run
6 hours ago $1.49 earnedBlack and White Cookies
113K1 -
2:45
SLS - Street League Skateboarding
4 days agoManny Santiago's 'THIS IS 40' Part
65.7K2 -
6:40
Homesteading Family
5 days agoNever Make Pie Crust From Scratch Again (Do THIS Instead)
54.9K5 -
44:20
Melissa K Norris
3 days ago $1.03 earnedThe Most Overlooked Way to Preserve Food for Months (No Freezer Needed) w/ Sam Knapp
39.7K1