Note 1:In the first and second sentences, 了le is placed after the verb (to indicate that the action is completed), followed by the duration. This is how you talk about the duration of completed actions. However,会huì is placed before the verb, followed by the duration.
Note 2:Also in the first Chinese sentence, “觉jiào” can be omitted because “睡shuì” means to sleep, “觉jiào” means a sleep. “睡shuì” is clear enough to express the action of sleeping when it goes with a complement. But for most other VO structure words, which the "object" is not the only object for the noun, you need to keep the object.
Note 3:Why did we repeat the "游yóu" in the last example, I bet you wondered about that huh? Basically, duration time has to come RIGHT AFTER THE VERB. In this case, "游yóu" is our verb and "泳yǒng" is the noun. There are many VO(verb-object) structure words in Chinese language and "游泳yóuyǒng" is one of them. By repeating the verb, we can have an object and a time duration in the same sentence! If that doesn't make sense, just remember the formula, cause it's a simple rule: verb + obj + verb + duration time. Since the question is asking about the "action (游泳yóuyǒng)" in the past, we do need to put "了le" after the "verb", "游yóu".
Note 4:When we answer this kind of questions or the context is clear, the object can be omitted. Like the fourth sentence, verb + duration time.
You can also make longer sentences by adding more elements.