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.
-
27:56
The Why Files
1 day agoThe Seventh Experiment: Lacerta Reveals the Truth of our Creation
51.5K52 -
45:53
hickok45
14 hours agoSunday Shoot-a-Round # 262
2.51K11 -
4:52:32
Rotella Games
21 hours agoGrand Theft America - GTA IV | Day 1
47K5 -
8:16:19
Joe Donuts Gaming
14 hours ago🟢Fortnite Live : Chill Vibes Lounge!
69K5 -
38:43
Standpoint with Gabe Groisman
10 hours agoEp. 63. Terror Strikes the Nova Music Festival. Ofir Amir
133K48 -
36:04
Forrest Galante
20 hours agoPrivate Tour of an Indian Billionaire’s Secret Wildlife Rescue Center
106K17 -
9:37
Space Ice
1 day agoMorbius Is The Perfect Movie, Everyone Just Lied To You - Best Movie Ever
94.9K30 -
17:09
Guns & Gadgets 2nd Amendment News
1 day agoWhy I Left The USCCA
82.9K42 -
21:33
Degenerate Jay
2 days ago $3.20 earnedThe Best Video Game Movie Ever Made? Sonic The Hedgehog 3 Movie Review
72K3 -
19:57
BlackDiamondGunsandGear
4 days agoIS 22LR ENOUGH?
99.3K31