Set in Python PYTHON by Ravinder Nath Rajotiya - April 10, 2022April 11, 20220 SETS in PYTHON A set is an unordered collection of items. Every element of a set is unique, i.e. there are no duplicate. A set itself is a mutable i.e. we can add or remove items in a set. Items of a set are immutable i.e. we cannot modify items of a set using its index. A set is declared using {} or in-built set() function How many items in a set: A set can have any number of integer, float, tuple, string types etc s={3,5,”Hello”, 3.14} What cannot be in a set: A set cannot have mutable elements like lists, sets or dictionaries as its elements. So it will be wrong to create a set: >>>s={3,5, [6,7], 3.14} error – set cannot have list as the set
Dictionary in Python PYTHON by Ravinder Nath Rajotiya - March 28, 2022March 29, 20220 DICTIONRY IN PYTHON Dictionary is a composite data type. It is used to represent records. The items in dictionary are represented by the key: value pairs. Declaration : A dictionary is declared by enclosing a comma-separated list of key-value pairs in curly braces. The value of an item is always accessed by using its key, therefore the key must be a unique name. Example dict={<key1> : <value>, <key2> : <value>, <key3> : <value>.......<keyn> : <value>} Th following define a dictionay that maps the capital to its country. capital_country = {‘Delhi’ : ‘India’, ‘Karachi’, ‘Pakistan’, ‘Kathmandu’ : ‘Nepal’ } Dictionary in python is similar to List in python. Let us see the similarty and differences between list and dictionary LIST DICTIONARY Is mutable Is mutable Can grow and shrink Can grow and
Introduction to Python PYTHON by Ravinder Nath Rajotiya - February 23, 2022March 13, 20220 Introduction to Python Python is one of the mostly used programming language in the world. Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. Guido van Rossum created this during 1985- 1990. Python is an open source programming language and its source code is available under the GNU General Public License (GPL). Some key features of python – Python is Interpreted: Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP. Python is Interactive: You can sit at a Python prompt and interact with the interpreter directly to write your programs. Python is Object-Oriented: Python supports Object-Oriented style or technique of programming
Django- User Profile Management Django by Ravinder Nath Rajotiya - January 13, 2022January 20, 20220 User Profile Management In the previous tutorial Django-User Login and Logout users able to login and logout. There was no user profile when they login. We need to have a user profile. Default Django view model does not have a feature to add user profile picture, We can do it by extending the user model to add more fields, In this tutorial we’ll learn how to use Django signals to run specific functions after certain actions which can be extremely useful for this type of work. We will extend user profile and create a profile model that will have a one-to-one relationship with the user. One-to-one relationship means that one user can have one profile and one profile will be associated with
Django-User Login and Logout Django by Ravinder Nath Rajotiya - January 11, 2022January 15, 20220 User Login and Logout: In this tutorial we are going to see how to create the authentication system for our Django applications so that the users can login, logout. Also the users need to be logged in, in order to access certain pages. The registration page created in the Django- Admin and Users registration post was used only by admin, but the users were not able to login. So, we have to create a login page for the frontend where users will be able to register, login or logout. Django has lot of functionality taking care for us at the backend. So, we get started with using the default LoginView If you want the users to login and have access to certain