# Live Metrics

First let’s have a look at the following two webpages…

#### Our Challenge

In this challenge we are going to write our own Python scripts to generate live metrics.

Let’s look at our first fact:

Every second, on average 10,260 tweets are tweeted on Twitter.

And check the Python script to make transform this fact into a “live metrics program”.

Should you have an issue running this code in Internet Explorer due to the line 2 instruction “import time”, try to display this page using Google Chrome instead.

Update the code above to create “live metrics” from the following facts:

On average 1,200 photos are posted on Instagram every second.
On average 98,000 youtube videos are viewed every second.
Google now processes over 107,000 search queries every second on average.

Around 80 million cars are produced in a single year worldwide.

To create a live metrics program based on this fact you will first need to use Python to calculate the number of cars produced in one second.

The current world population is estimated at: 7,985,000,000 human beings.
It is currently growing at a rate of around 1.05 % per year.

To create a live metrics program based on this fact you will first need to use Python to calculate the population growth (in human beings) in one second.
[pms-restrict display_to=”not_logged_in” message=” “]

#### Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
[/pms-restrict] [pms-restrict subscription_plans=”14217″ message=” “]

#### Solution...

You are viewing this solution as part of your full membership subscription!

Python Code

#### Python Code

```#Live Metrics Challenge - www.101computing.net/live-metrics
import time

#Initialise variables
numberOfTweets = 0
numberOfEmails = 0
numberOfCars = 0
worldPopulation = 7985000000

#Repeat every 1 second:
while True:
time.sleep(1)
#Every second, around 10,260 tweets are tweeted on Twitter
numberOfTweets += 10260
print("Since you started this program " + str(numberOfTweets) + " tweets have been tweeted on Twitter")

#Every second, around 98,000 youtube videos are viewed every second.
numberOfVideos += 98000
print("Since you started this program " + str(numberOfVideos) + " videos have been viewed on Youtube.")

#Every second, around 1,200 photos are posted on Instagram every second.
numberOfPhotos += 1200
print("Since you started this program " + str(numberOfPhotos) + " photos have been posted in Instagram.")

#Every second, around 107,000 google search queries
print("Since you started this program " + str(numberOfGoogleSearches) + " Google searches have been requested.")

#Every year 60 millions cars are sold aroung the world
#Calculate number of cars sold per seconds
numberOfCars += 80000000/(365*24*60*60)
print("Since you started this program " + str(int(numberOfCars)) + " cars have been sold around the world.")

#The world population is currently growing at a rate of around 1.05 % per year.
worldPopulation += worldPopulation * (1.05 / 100) / (365 *24 *60 *60)
print("World Population: " + str(int(worldPopulation)))
```
[/pms-restrict]

Did you like this challenge?

Click on a star to rate it!

Average rating 4.7 / 5. Vote count: 34

No votes so far! Be the first to rate this post.

As you found this challenge interesting...