Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Average Tempo by Key | Section 3
Python - Music

Swipe um das Menü anzuzeigen

book
Average Tempo by Key

Aufgabe

Swipe to start coding

Complete a function that calculates the average tempo (in beats per minute, BPM) of tracks for each musical key. Each track is represented as a dictionary containing various fields, including tempo and key.

Inputs:

  • tracks: A list of dictionaries, where each dictionary represents a track and contains at least the following fields:
    • tempo: A float representing the tempo of the track in BPM.
    • key: An integer representing the musical key of the track, ranging from 0 to 11.

Steps:

  • Iterate Through Keys:

    • Loop through each musical key from 0 to 11.
    • For each key, create a list key_tempos that contains the tempo of tracks with the current key.
  • Calculate Average Tempo:

    • If key_tempos is not empty, calculate the average tempo by summing the tempos and dividing by the number of tempos.
    • Store the calculated average tempo in average_tempos with the current key as the dictionary key.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 6
py

solution.py

py

main.py

Fragen Sie AI

expand
ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

book
Average Tempo by Key

Aufgabe

Swipe to start coding

Complete a function that calculates the average tempo (in beats per minute, BPM) of tracks for each musical key. Each track is represented as a dictionary containing various fields, including tempo and key.

Inputs:

  • tracks: A list of dictionaries, where each dictionary represents a track and contains at least the following fields:
    • tempo: A float representing the tempo of the track in BPM.
    • key: An integer representing the musical key of the track, ranging from 0 to 11.

Steps:

  • Iterate Through Keys:

    • Loop through each musical key from 0 to 11.
    • For each key, create a list key_tempos that contains the tempo of tracks with the current key.
  • Calculate Average Tempo:

    • If key_tempos is not empty, calculate the average tempo by summing the tempos and dividing by the number of tempos.
    • Store the calculated average tempo in average_tempos with the current key as the dictionary key.

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 6
Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
Wir sind enttäuscht, dass etwas schief gelaufen ist. Was ist passiert?
some-alt