Category : Python

Email import collections dict1 = {‘day1’: ‘Mon’, ‘day2’: ‘Tue’} dict2 = {‘day3’: ‘Wed’, ‘day1’: ‘Thu’} res= collections.ChainMap(dict1, dict2) print(res.maps,’n’) print(‘Keys =’, format(list(res.keys()))) print(‘values =’,format(list(res.v..

Read more

Emailfrom array import * t= [[1,3,4],[3,4,5],[4,5,6],[4,5,4]] # this coding inset of the coding t.insert(1,[0,0,0]) # this cosing is the update of the coidng t[2]=[11,9] t[0][2]= 7 # this is the coding is the delete of the codig del t[2] for i in t: for c in i: print(c,end= ” &#8220..

Read more

Email# this fuction are using the dist diste= {‘name’:’coding anil’, ‘age’:3} print (diste[‘name’]) # this coding is the update codig diste[‘name’]= “this best coding anil” print(diste[‘name’]) # delete coding del diste[‘age’] pr..

Read more

Email Traverse − print all the array elements one by one. Insertion − Adds an element at the given index. Deletion − Deletes an element at the given index. Search − Searches an element using the given index or by the value. Update − Updates an element at the given index.   from array import * name = array(‘i’,[43,5,4,3,2,24,5]) # ..

Read more

Emailfrom array import* array1 = array(‘i’,[30,40,20,30,20,40,30]) if array1[0] / 2 == 0: print(“this codig working”) else: print(“not working”) array1.insert(1,000000) array1.remove(0) print(“this searching postion”,array1.index(30)) array1[4]= 4 for i in array1: print(i) total=array1[0]+array1[1] print(total) sumall = sum(array1); prin..

Read more

EmailOver the past decade, the popularity of Python as a mainstream programming language has exploded. Notable advantages of Python over other languages include, but are not limited to; It is a very simple language to learn and easy to implement and deploy, so you don’t need to spend a lot of time learning lots of ..

Read more

EmailThis code error in we are adding one string and one number here we cannot add the string and number Traceback (most recent call last): File “C:/Users/root/Tkineter Project tutorial/venv/ad2.py”, line 5, in <module> print(b+a) TypeError: can only concatenate str (not “int”) to str expl: a = 3 b = “this string ” print(b+a) right code: ..

Read more

Email# Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases # DATABASES = { # ‘default’: { # ‘ENGINE’: ‘django.db.backends.sqlite3’, # ‘NAME’: os.path.join(BASE_DIR, ‘db.sqlite3’), # } # } # Database # https://docs.djangoproject.com/en/2.1/ref/settings/#databases DATABASES = { ‘default’: { ‘ENGINE’: ‘djongo’, ‘NAME’: ‘sigm..

Read more

Email views.py from django.shortcuts import render from django.http import HttpResponseRedirect, HttpRequest from django.contrib.auth import authenticate, login,logout from django.contrib.auth.decorators import login_required from .forms import Reigsterfrom from django.contrib.auth.models import User   def user_register(request): template = ‘login/register.html’ if request.method ==’POST’: form = Reigsterfrom(request.POST) if form.is_valid(): if User.objects.filter(email=form.cleaned_data[’email’]).exists(): return render(request, template, { ‘form’: form, ‘error_message’: ‘Email already exists.’ }) ..

Read more

Email Pip Install flask # -*- coding: UTF-8 -*- “”” hello_flask: First Python-Flask webapp “”” from flask import Flask # From module flask import class Flask app = Flask(__name__) # Construct an instance of Flask class for our webapp @app.route(‘/’) # URL ‘/’ to be handled by main() route handler def main(): “””Say hello””” return ..

Read more

Email In Mongo db and sqlit sql mysql  t DATABASES = { ‘default’: { ‘ENGINE’: ‘djongo‘, ‘NAME’: ‘mydb&#..

Read more

Emailfrom django.db import models class Api(models.Model): name = models.CharField(max_length=30) lasnname = models.CharField(max_length=50) lasnname = models.CharField(max_length=30) phonenumber = models.CharField(max_length=30) def __str(self): return self.name + ‘—-‘+self.lasnname class Song(models.Model): movie = models.ForeignKey(Api, on_delete=models.CASCADE) file_type = models.CharField(max_length=50) song_name = models.CharField(max_length=30) class emplist(models.Model): name = models.CharField(max_length=20) title = models.TextField() body = models.SlugField() createdata = models.DateTimeField(auto_now=True) author = models.ForeignKey(Api, on_delete=model..

Read more

Email from django.shortcuts import render from django.http import HttpResponse # please check like that def index(request): return render(request,’index/index.html’, context=’home’)     Step 2:- ‘DIRS’: [‘C:/Users/naikA/Desktop/simg/sigmav/sigmav/templates’],     TEMPLATES = [ { ‘BACKEND’: ‘django.template.backends.django.DjangoTemplates’, ‘DIRS’: [‘C:/Users/naikA/Desktop/simg/sigmav/sigmav/templates’], ‘APP_DIRS’: True, ‘OPTIONS’: { ‘context_processors’: [ ‘django.template.context_processors.debug’, ‘django.template.context_processors.request’, ‘django.contrib.auth.context_processors.auth’, ‘django.contrib.messages.context_processors.messages’, ..

Read more

EmailWhat is the problem this coding? step1: Your create the folder name and project name same You change the folder name or project pr..

Read more

Email from http.server import HTTPServer, BaseHTTPRequestHandler class Serv(BaseHTTPRequestHandler): defdo_GET(self): ifself.path ==’/’: self.path =’/index.html’ try: file_to_open = open(self.path[1:]).read() self.send_response(200) except: file_to_open = “File not found” self.send_response(404) self.end_headers() self.wfile.write(bytes(file_to_open, ‘utf-8’)) httpd = HTTPServer((‘localhost’, 8080), Serv) httpd.serve..

Read more

Email name = input(“What’s your name? “) What’s your name? “John” >>> >>> age = input(“Your age? “) Your age? 38 >>> print(age, type(age)) (38, <type ‘int’>) >>> colours = input(“Your favourite colours? “) Your favourite colours? [“red”,”green”,”blue”] >>> print(colours) [‘red’, ‘green’, ‘blue’] >>> print(colours, type(colours)) ([‘red’, ‘green’, ‘blue’], <type ‘list’>) &g..

Read more

Emaildef LongestWord(): # first we remove non alphanumeric characters from the string # using the translate function which deletes the specified characters sen = sen.translate(None, “~!@#$%^&*()-_+={}[]:;'<>?/,.|`”) # now we separate the string into a list of words arr = sen.split(” “) # the list max function will return the element in arr # with the ..

Read more