Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Tracks Total Duration | Section 3
Python - Music

Glissez pour afficher le menu

book
Tracks Total Duration

Tâche

Swipe to start coding

Complete a function that calculates the total duration of all tracks in a list, converting the duration from milliseconds to minutes. Each track is represented as a dictionary containing various fields, including a duration_ms field that indicates the track's duration in milliseconds.

Inputs:

  • tracks: A list of dictionaries, where each dictionary represents a track and contains at least the following field:
    • duration_ms: An integer representing the duration of the track in milliseconds.

Steps:

  • Iterate Through Tracks:

    • Loop through each track in the tracks list.
    • For each track, add its duration_ms value to total_duration_ms.
  • Convert to Minutes: After summing the durations in milliseconds, convert total_duration_ms to minutes by dividing it by 60,000 (since there are 60,000 milliseconds in a minute).

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 3
py

solution.py

py

main.py

Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?

Demandez à l'IA

expand
ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

book
Tracks Total Duration

Tâche

Swipe to start coding

Complete a function that calculates the total duration of all tracks in a list, converting the duration from milliseconds to minutes. Each track is represented as a dictionary containing various fields, including a duration_ms field that indicates the track's duration in milliseconds.

Inputs:

  • tracks: A list of dictionaries, where each dictionary represents a track and contains at least the following field:
    • duration_ms: An integer representing the duration of the track in milliseconds.

Steps:

  • Iterate Through Tracks:

    • Loop through each track in the tracks list.
    • For each track, add its duration_ms value to total_duration_ms.
  • Convert to Minutes: After summing the durations in milliseconds, convert total_duration_ms to minutes by dividing it by 60,000 (since there are 60,000 milliseconds in a minute).

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 3
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Nous sommes désolés de vous informer que quelque chose s'est mal passé. Qu'est-il arrivé ?
some-alt