Posts

Showing posts from July, 2021

Python-Cheat-Sheet

Image
Python-Cheat-Sheet Variables We use variables to temporarily store data in the computer’s memory. price = 10 rating = 4.9 course_name = ‘Python for Beginners’ is_published = True In the above example, • price is an integer (a whole number without a decimal point) • rating is a float (a number with a decimal point) • course_name is a string (a sequence of characters) • i s_published is a boolean. Boolean values can be True or False. Comments We use comments to add notes to our code. Good comments explain the hows and whys, not what the code does. That should be reflected in the code itself. Use comments to add reminders to yourself or other developers, or also explain your assumptions and the reasons you’ve written code in a certain way. # This is a comment and it won’t get executed. # Our comments can be multiple lines. Receiving Input We can receive input from the user by calling the input() function. birth_year  =  i nt(input(‘Birth year: ‘)) The input() function always returns da

Model View Controller Pattern (MVC)

Image
 Model View Controller Pattern (MVC) What is MVC? - MVC stands for Model-View-Controller, a common pattern for architecting web applications. - As well as a term that we use very commonly in the industry, for indicating which parts of an application we are currently managing or touching.     - The Model-View-Controller pattern is a way of Thinking of our application in terms of three layers.  Describes the 3 layers of the application we are developing: 3-Layers: 1- Models : Manage data and business logic for us.  What happens inside models and databases, capturing logical relationships and properties across the web app objects. 2- Views : Handles display and representation logic.  What the user sees (HTML, CSS, JS from the user's perspective). 3- Controllers : Routes commands to the models and views, containing control logic. Control how commands are sent to models and views, and how models and views wound up interacting with each other. Explanation - The Models layer manages data

Building out a CRUD application

Image
 Building out a CRUD application What CRUD means? So to create a CRUD application, let's first learn CRUD. CRUD stands for Create, Read, Update, Delete. C == Create R == Read U == Update D == Delete For every one of these verbs, There are equivalent SQL statements that match that verb for want to do to a database.  Create: Whenever we want to create an object in our web application, We want to commit an insert statement in our relational database. Read: When we want to read records from the user's perspective on a web application, We want to select certain records from our database so that we can feed them into the view that the client sees.  Update : When we want to update something from the user's perspective, The user clicks a button, checks the checkbox, or submits a form.            Changing something that already exists in that web application, we want to execute an update statement to our database.   Delete: Finally, when a user chooses to remove something and dele