Think Python X3: Difference between revisions

From XPUB & Lens-Based wiki
(New page: == Exercise X3.1 == Recall [Think Python X2#Exercise X2.1 | the previous exercise] about calculating time codes from an SRT file. Write a function that takes hours, minutes, seconds,...)
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Exercise X3.1 ==
== Exercise X3.1 ==


Recall [Think Python X2#Exercise X2.1 | the previous exercise] about calculating time codes from an SRT file. Write a [[function]] that takes hours, minutes, seconds, and fraction as [[parameter | parameters]] and returns the raw number of seconds.
Recall [[Think Python X2#Exercise X2.1 | in Exercise X2.1]] how you could convert a time code from an SRT file. Write a [[function]] that takes hours, minutes, seconds, and fraction as [[parameter | parameters]] and returns the raw number of seconds.
   
   
Hint: Start with your python expression from the previous exercise; replace "hard-coded" numbers with variables for each for the parameters listed above. Wrap this new expression inside a function defintion, with the given parameters, and remember to use the return keyword to pass the result back out when the function gets called.
Hint: Start with your python expression from the previous exercise; replace "hard-coded" numbers with variables for the parameters listed above. Wrap this new expression inside a function definition (name it, list the parameters), and finally remember to use the return keyword to pass the result back out when the function gets called.

Latest revision as of 21:00, 13 October 2008

Exercise X3.1

Recall in Exercise X2.1 how you could convert a time code from an SRT file. Write a function that takes hours, minutes, seconds, and fraction as parameters and returns the raw number of seconds.

Hint: Start with your python expression from the previous exercise; replace "hard-coded" numbers with variables for the parameters listed above. Wrap this new expression inside a function definition (name it, list the parameters), and finally remember to use the return keyword to pass the result back out when the function gets called.