Earn money online
import random
class Blogger:
def __init__(self, name):
self.name = name
self.articles = []
def write_article(self, title, content):
article = Article(title, content)
self.articles.append(article)
def monetize(self):
earnings = 0
for article in self.articles:
views = random.randint(100, 10000) # Simulating random number of views
click_through_rate = random.uniform(0.5, 5) / 100 # Simulating random CTR
cost_per_click = random.uniform(0.01, 0.5) # Simulating random CPC
clicks = views * click_through_rate
earnings += clicks * cost_per_click
return earnings
class Article:
def __init__(self, title, content):
self.title = title
self.content = content
# Example usage:
blogger = Blogger("John Doe")
blogger.write_article("Top 10 Tips for Online Money Making", "Content goes here")
blogger.write_article("How to Start an Online Business", "Content goes here")
blogger.write_article("5 Passive Income Ideas", "Content goes here")
total_earnings = blogger.monetize()
print(f"{blogger.name} earned ${total_earnings:.2f} from their articles.")
Comments
Post a Comment