1. Create a Python script that computes the number of songs that can be stored o
ID: 3875412 • Letter: 1
Question
1. Create a Python script that computes the number of songs that can be stored on a flash drive in a digital music player.
Background information:
>the default bit sampling rate for ripping a CD into the iTunes AAC music format is 256 kbps
•for data sampling purposes, 'k' is 10^3
•the 'b' stands for bit, the fundamental digital storage unit
•'kbps' then is 1000 bits / second of encoded music
>the average song lasts 4 minutes
>flash drives range in size from from 2GB to 160GB
•for storage purposes, 'G' is 2^30
•the 'B' stands for byte, a digital storage unit consisting of 8 bits
Compute:
Using the above data, create a Python script that reports the average number of songs an 8GB flash drive can hold.
Explanation / Answer
python script:--
k=10**3 #kilo bits value
G=2**30 #Giga Bytes value
#average song length in minutes
one_song_lenght_seconds=one_song_Avglenght_min*60 #average song length in seconds
AAC_memory_rate=256*k #AAC format speed
one_song_memory_bits=AAC_memory_rate*one_song_lenght_seconds #total memory required per one song in bits
print('average memory per one song in bits is: ',one_song_memory_bits)
flashdrive_capacity_Bytes=8*G #flash drive capacity in Bytes
flashdrive_capacity_bits=flashdrive_capacity_Bytes*8 #flash drive capacity in bits
print('8GB flash drive capacity in bits is: ',flashdrive_capacity_bits)
Number_of_songs=flashdrive_capacity_bits//one_song_memory_bits #number of songs for 8GB
print('Number of songs stoted in 8GB flash drive with 4 min average length of songs are: ',Number_of_songs)
Output:--
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
=============== RESTART: D:/Real-world/Python/DVD_8GB_songs.py ===============
average memory per one song in bits is: 61440000
8GB flash drive capacity in bits is: 68719476736
Number of songs stoted in 8GB flash drive with 4 min average length of songs are: 1118
>>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.