Git Product home page Git Product logo

python-review's Introduction

Python Review

Objective:

In this lab, you will practice the previous topics we have learned before during the yearlong!
Refreshing your memories and reviewing specifically: Python basics, Lists, Dictionaries & Functions.

First things first, fork this repo(sitory) and clone it to your desktop!

In this section, you are an engineer at Youtube!
Susan, the CEO of Youtube, asks you to create an easier way to access, modify, and create youtube videos.
You have an idea! Why not use Dictionaries? it's going to be super easy to do all of the requirements using them.

  1. Create a new Python file, called pythonReview.py.

  2. In pythonReview.py, create a new function called create_youtube_video.

    • It should take 2 inputs:
      • title
      • description
    • The function should create a new youtube video dictionary with the following keys:
      • title - The title/name of the video, and its value is the input.
      • description - The description of the video/Short explanation about the video, and its value is the input.
      • likes - Number of likes, should start equal to 0 as a value.
      • dislikes - Number of dislikes, should start also equal to 0 as a value.
      • comments - A dictionary of comments, where the "username" is the key, and the comment text is the value. Should start empty as a value.
    • The function returns the dictionary.
  3. Define a new function called like:

    • The function takes a dictionary (youtube video) as an input
    • the function checks if likes is a key in the dictionary, if it is then it should add 1 to the value.
    • The function returns the dictionary.
  4. Define a similar function, call it dislike. The function should add 1 dislike to the key dislikes if it's in the dictionary.

  5. Define a new function, call it add_comment. The function should take 3 attributes:

    1. youtubevideo - The dictionary that contains the youtube video info.
    2. username - The username of the commenter.
    3. comment_text - The actual comment!
    • The function should add "username" as a key to "comments" dictionary, and "comment_text" as the value.
    • The function returns the dictionary.
  6. Create a new youtube video dictionary, and fill in the attributes!

    • Test out all of the object's functions.
    • How would you add 495 likes?
    • Show your neighbor!
Great job on completing your first Lab!
Call an Instructor/TA to check your completed tasks

If you have extra time, continue to the Bonus Problems below.
If not, make sure you commit and push your code.

Bonus Problems:

If you have finished and still have time, first of all GOOD JOB!

  1. Let's make a recommended videos algorithm!!
    • Firstly, add a key to the dictionary in create_youtube_video, call it hashtag. It should be a list up to 5 words that describe the video (the list should be taken as an input in the function).
    • Come up with a function called similarity_to_video, the function should take two youtube video dictionaries and return the percentage of similarity of the two videos!

make sure you commit and push your code.

python-review's People

Contributors

fouadhadd avatar jenny-df avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.