Skip to main content

Posts

Showing posts from August 14, 2018

Django Project Setup

DJANGO Django is a high-level Python Web-Development framework. In this post, we will learn how to set up our first Django project with MySql database. Contents Virtual Environment Install Django MySql Setup  Create Application Other Setting  Virtual Environment  Virtual Environment is an extremely useful tool that helps us to keep our coding environment tidy on our computer. Let's create the virtual environment. Create a directory for your project mkdir Django cd Django Install a virtual environment python3 -m venv your_virtual_env_name Working with the virtual environment source your_virtual_env_name/bin/activate Install Django Before installing Django make sure that you are inside your virtual environment. your_virtual_env_name$ Install Django pip install django~=1.11.0 Create Project django-admin startproject your_site_name . MySql Set Up Open your_site_name/setting.py and f...

Python Tutorial

PYTHON DATA STRUCTURE Data Structure is a way to organizing and storing data in computer memory so that we can access and modify it efficiently. In this post, we will learn about some cool feature of python data structure. Python Data Structure Python has following commonly used data structure. List Tuple Set Dictionary List In Python, List is the most versatile data structure which can be written as a list of comma separated values between square brackets. Create list #Question: Create an empty list in python #Answer: my_first_list = [] #Question: Create a list containg numbers 1, 2, 3, 4, 5 #Answer:my_second_list = [1, 2, 3, 4, 5] Insert in list #Question: Store 1, 2, 3, 4, 5 in a list say my_list #Answer: my_list = [1, 2, 3, 4, 5] #Question: Store dynamic value in list say my_list. like from 5 to 1000 #Answer: my_list = [] for i in xrange(5, 1001): my_list.append(i) my_list.append(x) insert value x at the end of the list Access/Read lis...

Python Tutorial

PYTHON DATA STRUCTURE Data Structure is a way to organizing and storing data in computer memory so that we can access and modify it efficiently. In this post, we will learn about some cool feature of python data structure. Python Data Structure Python has following commonly used data structure. List Tuple Set Dictionary In our  previous post , we have already learned a lot about the list. In this post, we will learn about Tuple, Set, and Dictionary data structure. Tuple A tuple consists of a number of values separated by commas. Create Tuple #Question: Create a tuple of numbers 1, 2, 3, 4, 5 #Answer: my_tuple = 1, 2, 3, 4, 5 or, my_tupe = (1, 2, 3, 4, 5) Both of above syntax is correct. There is the special syntax to construct of tuples containing 0 or 1 items. #Question: Create tuple contain 0 item #Answer: my_tuple = () #Question: Create tuple contain 1 item #Answer: my_tuple = '1', Empty tuples are constructed by an empty pair of parenthe...

Python - Object Oriented

PYTHON OBJECT-ORIENTED Object-oriented programming is a programming paradigm in which are based on the concept of Object. Python also supports some features of Object-oriented programming (OOP). In this post, We will learn about these features. Python OOPS Concept Class Object Method Inheritance  Class In programming languages class provide a way to bundle data and functionality together. The simplest form of class definition syntax will look like class ClassName (): < statement - 1 > . . . < statement - n > Example class Calculate (): x = 1 Object An object is an instance of a class. Syntax to create an object of above class  Calculate  is objectName = ClassName (): Example obj = Calculate () We can access variable x with the syntax.  objName.VariableName obj . x Method class Calculate (): x = 1 def fun ( self ): print ('This is a method'...