Tag: Python Tutorial

Python Essentials | Python Basics Tutorial

In this Python tutorial, you will learn about some essentials of Python. The topics that we are going to discuss are:

  • Statements
  • Expressions
  • Multiline Statements
  • Indentation
  • Comments
  • Identifiers
  • Keywords
  • Naming Convention

Read More

Python Variables( Global, Local, Nonlocal) , Constants

Hellow Programmers, In this python tutorial I am gonna talk about variables & their types. So What is Variable?

Variable: Think about an empty pot in which you can put anything. In programming we call it variable. Actually a variable is an empty memory location to store values.

How to declare a variable in python?

Declaring a variable in python is a piece of cake. Name it & put a value into it. As python is a dynamically typed language we don't need to declare variable types. Python is smart enough to detect the type itself.

There are some rules of declaring variables:

  • A variable name must start with a letter or the underscore character.
  • Cannot start with a number.
  • A variable name can only contain alpha-numeric characters and underscores. For example, anything like this is valid: A-z, 0–9, and _
  • Variable names are case-sensitive (height, Height, and HEIGHT are three different variables names)

Read More

Python Dictionaries – All You Need To Know

Hello geeks, in this python 3 tutorial, you are going to learn A to Z of Python dictionary. We will discuss the followings:

  • What is Python Dictionary?
  • How to create a Dictionary!
  • Add, Delete, Update Elements.
  • Access Elements of a Dictionary.
  • Merging Two Dictionaries
  • Creating Nested Dictionary
  • Adding, Deleting, Updating elements in a Nested Dictionary.
  • Different Methods of Python Dictionary.
  • copy(), fromkeys(), get(), pop(), popitem(), items(), keys(), values()

So, without further ado let’s jump into it.

What is Python Dictionary?

Python dictionary is a data type of python programming language. It stores data by mapping them with a key. Data are stored in “Key-Value” pairs where each “Key” must be unique. Lists, Tuples can also be stored as value in a dictionary.

Read More

Django Models, Python Django Tutorial

We have discussed how to create a Django project and Django app in our first Django tutorial. In this tutorial, we will talk about Django models. We will cover the following topics:

  • Creating a model.
  • Registering Model in django admin site.
  • 'Class Meta' in django models.
  • Creating Objects of Models
  • __str__ Method of django models.
  • get_absolute_url() method of django models.
  • @property in django model.
  • Django Model Fields

Model is a structure for storing data. The model handles everything related to data. Such as: data access, data validation, dealing with data of other models, etc.  It mirrors the fields and behaviors of the data. Generally a model is implemented as a python class which is a subclass of django.db.models.Model. Django gives an automatically-generated database-access API to create a table in our database by each model, and the "attributes" of the table are created by the "fields" of the model class. Models are defined inside an app’s ‘models.py’ file. 

Read More

Powered by WordPress & Theme by Anders Norén