dd=3
mm=4
yyyy=2021
print(dd,mm,yyyy,end="",sep="kfdjdskjgshgjhsfdjghdsjfg")
print("03-04-2021")
dd=3
mm=4
yyyy=2021
#print("dd-",dd,"mm-",mm,"yyyy-",yyyy,end="",sep="")
#print("03-04-2021")
#print("dd{}-mm-{}-yyyy-{}".format(mm,dd,yyyy))
#print("%d-%d-%d",dd,mm,yyyy)
#print(dd,mm,yyyy)
#boolean=2values
#True----->1
#False---->0
a=True
print(a)
a=False
print(a)
print(True)
print(False)
#operations on number
#+,_,/,%,**,<,>>=,<=,!,!=
#addition---'+'
a=1054545454545454545454421231545313248432132454
b=206545423132468484543545484843415454564545121324874987524154879848544564654564564654548798798
a=a+b
#print(a)
a=a+a+b+a+a+b+b+a+a+b+b+b+b+a+a+b+b+a+a+b+a+b+b+b
b=a+a+b+a+a+b+b+a+a+b+b+b+b+a+a+b+b+a+a+b+a+b+b+b
#print(a+b)
#subtraction ---'-'
a=20
b=10
c=a-b
print(c)
#multiplication---'*'
a=205454564545454545132132156456451234156456451545456456451341
b=10657484564354846454654845645467484546546546
c=454545454546545453423132545454545465456456454554
print(a*b*c)
print(a*b*c*a*b*c)
#BODMAS
#B-brackets
#O-of
#D-division
#M-multiplication
#A-addition
#s--substraction
print((5*4)+10)
#division---'/'
a=10
b=2
#print(type(a),type(b))
c=a/b
print(c)
a=10
b=2
#print(type(a),type(b))
c=a/b
print(c)
#floor division
a=11
b=2
#print(type(a),type(b))
c=a//b
print(c)
a=115465454564564545454545454545
b=2
#print(type(a),type(b))
c=a//b
print(c)
#power **
print(2**5)
print((2**5)**2)
print(10**2)
"""
print "jyothi laxmi" #2.0
#integer----int
#string-----str
#float------float
#char--------xxxxxx not available
embedded system,Arduino,Raspberry pi,ARM7,MM32,STM32,PIC and Python,Django,Datascience and web development
Saturday, April 3, 2021
Wednesday, March 24, 2021
python introduction day1
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> 5+10
15
>>> a=5
>>> print(a)
5
>>> print(type(a))
>>> b=10
>>> print(b)
10
>>> print(type(b))
>>> c=a+b
>>> print(c)
15
>>> print(type(c))
>>> a="saikumar"
>>> print(a)
saikumar
>>> print(type(a))
>>> print(id(a))
23484040
>>> print(id(a))
23484040
>>> print(id(b))
1656382704
>>> a=15
>>> a
15
>>> type(a)
>>> id(a)
1656382784
>>> a=20
>>> id(a)
1656382864
>>>
15
>>> a=5
>>> print(a)
5
>>> print(type(a))
>>> b=10
>>> print(b)
10
>>> print(type(b))
>>> c=a+b
>>> print(c)
15
>>> print(type(c))
>>> a="saikumar"
>>> print(a)
saikumar
>>> print(type(a))
>>> print(id(a))
23484040
>>> print(id(a))
23484040
>>> print(id(b))
1656382704
>>> a=15
>>> a
15
>>> type(a)
>>> id(a)
1656382784
>>> a=20
>>> id(a)
1656382864
>>>
Tuesday, March 16, 2021
django day6 class html input
https://drive.google.com/file/d/1z8wgE8vx-OeX4j-0ii7LjAHMddpDKMNk/view?usp=sharing
Sunday, March 14, 2021
django day 5 view page logic
View.py
=====================
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home(request):
#1+2
#HttpResponse("
urls.py
===================================
from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
path('',views.home,name="home"),
path('contact',views.contact,name="contact")
]
this is homepage
") #return HttpResponse("this is test2 app homepage
") user="ranjith" context={'name':user} if user == "chandu": #context={'name':user} return render(request, "home.html", context) elif user == "ranjith": return render(request, "contact.html", {'price':1000}) else: return render(request, "home.html", context) def contact(request): return HttpResponse("this is app contactpage
") contact.html =========================HTML Table
| Company | Contact | price |
|---|---|---|
| Alfreds Futterkiste | Maria Anders | {{price}} |
| Centro comercial Moctezuma | Francisco Chang | {{price}} |
| Ernst Handel | Roland Mendel | Austria |
| Island Trading | Helen Bennett | UK |
| Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |
| Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |
Monday, March 8, 2021
django day4 first app running
your app urls.py
=====================
from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
path('',views.home,name="home"),
path('contact',views.contact,name="contact")
]
your app views.py
======================
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home(request):
#1+2
#HttpResponse("
this is homepage
") #return HttpResponse("this is test2 app homepage
") return render(request, "home.html", {'name': "the king"}) def contact(request): return HttpResponse("this is app contactpage
") template--home.html ========================this is templates page home page{{name}}
this is templates page home page{{name}}
this is templates page home page{{name}}
this is templates page home page{{name}}
this is templates page home page{{name}}
this is templates page home page{{name}}
project urls.py ============================= from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',include('test2.urls')), path('admin/', admin.site.urls), ]Sunday, March 7, 2021
django day3
#urls.py
from django.contrib import admin
from django.urls import path,include
from . import views
urlpatterns = [
path('',views.home,name="home"),
path('contact',views.contact,name="contact"),
path('aboutus',views.aboutus,name="aboutus"),
path('admin/', admin.site.urls),
]
#views.py
from django.http import HttpResponse
def home(request):
#1+2
#HttpResponse("
this is homepage
") return HttpResponse("this is firstpage
") def contact(request): return HttpResponse("this is contactpage
") def aboutus(request): return HttpResponse("about page
")Friday, March 5, 2021
sep, end in print method in python
"""
print(10,20,30,sep='@')
print(10,20,end='')
print(" ", 30)
#print(input("enter number"))
#print("you opened django server with IP:http://127.0.0.1:8000\n")
def ranjith():
print("ranjith is basha")
print("chandu is king")
ranjith()
def connect():
print("you opened django server with IP:http://127.0.0.1:8000\n")
def disconnect():
print("it is disconnected")
connect()
while(1):
print("basha")
disconnect()
i=0
if(i==0):
print("rajinikanth")
else:
print("ramyakrishna")
"""
Friday, February 12, 2021
day 35 table widget and text widget
from tkinter import *
import pymysql
def create_table():
conn=pymysql.connect(host="localhost",user="root",password="",db="sslabs")
mycursor=conn.cursor()
print("inside create table")
#mycursor.execute("CREATE TABLE hotel (id INT AUTO_INCREMENT PRIMARY KEY, dosa VARCHAR(255), add VARCHAR(255), idle VARCHAR(255) )")
#sql = "INSERT INTO hotel (dosa, idle, add) VALUES (%s, %s, %s)"
mycursor.execute("CREATE TABLE hotel (id INT AUTO_INCREMENT PRIMARY KEY, dosa VARCHAR(255),idle VARCHAR(255), sum VARCHAR(255))")
#1234514532
#sub=e3.get()
#val = (dosa1, idle1)
#mycursor.execute(sql, val)
conn.commit()
print(mycursor.rowcount, "record inserted.")
def display():
#create_table()
conn=pymysql.connect(host="localhost",user="root",password="",db="sslabs")
mycursor=conn.cursor()
#print("First Name: %s\nstandard:%s\nsubject:%s" % (e1.get(),e2.get(),e3.get()))
#query = "SELECT * FROM student"
## getting records from the table
#mycursor.execute(query)
## fetching all records from the 'cursor' object
#records = mycursor.fetchall()
## Showing the data
#for record in records:
#print(record)
a=e1.get()
a=int(a)
print(type(a))
b=e2.get()
b=int(b)
print(type(b))
sql = "INSERT INTO hotel (dosa, idle,sum) VALUES (%s, %s,%s)"
c=a+b
#sub=e3.get()
val = (a,b,c)
mycursor.execute(sql, val)
Label(praveen , text=a).grid(row=5)
conn.commit()
praveen=Tk()
#root=Tk()
praveen.geometry("500x300")
#root.geometry("500x300")
praveen.title("Hotel management")
#root.title("Hostel management")
Label(praveen, text="dosa").grid(row=0)
Label(praveen , text="idle").grid(row=1)
e1=Entry(praveen)
name=e1.grid(row=0,column=1)
#e3=Entry(root)
#name=e3.grid(row=0,column=1)
e2=Entry(praveen)
standard = e2.grid(row=1,column=1)
Button(praveen,text='Quit', command=praveen.quit).grid(row=2,column=0,sticky=W,pady=4)
Button(praveen,text='display', command=display).grid(row=2,column=1,sticky=W,pady=4)
#Button(praveen,text='Insert', command=create_table).grid(row=2,column=2,sticky=W,pady=4)
mainloop()
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 11 22:45:50 2021
@author: Onyx1
"""
from tkinter import *
import pymysql
root = Tk()
# specify size of window.
root.geometry("250x170")
# Create text widget and specify size.
T = Text(root, height = 5, width = 52)
T.pack()
# Create label
l = Label(root, text = "Fact of the Day")
l.config(font =("Courier", 14))
l.pack()
Fact = """A man can be arrested in
Italy for wearing a skirt in public."""
# Create button for next text.
b1 = Button(root, text = "Next", )
b1.pack()
# Create an Exit button.
b2 = Button(root, text = "Exit",
command = root.destroy)
b2.pack()
# Inserroot The Fact.
#root.insert(root.END, Fact)
root.mainloop()
day 36 menu bar using python
#from tkinter import Toplevel, Button, Tk, Menu ,Label
from tkinter import *
top = Tk()
def display_text():
w = Label(top,text="Hello Tkinter")
#new_win=Tk()
#new_win.geometry("300*400")
w.pack()
menubar = Menu(top)
file = Menu(menubar, tearoff=0)
file.add_command(label="New",command=display_text)
file.add_command(label="Open")
file.add_command(label="Save")
file.add_command(label="Save as...")
file.add_separator()
file.add_command(label="print")
file.add_command(label="print preview")
file.add_command(label="Close")
file.add_command(label="Exit", command=top.quit)
menubar.add_cascade(label="File", menu=file)
edit = Menu(menubar, tearoff=0)
edit.add_command(label="Undo")
edit.add_command(label="Cut")
edit.add_command(label="Copy")
edit.add_command(label="Paste")
edit.add_separator()
edit.add_command(label="Delete")
edit.add_command(label="Select All")
menubar.add_cascade(label="Edit", menu=edit)
help = Menu(menubar, tearoff=0)
help.add_command(label="About")
menubar.add_cascade(label="Help", menu=help)
view = Menu(menubar, tearoff=0)
view.add_command(label="View")
menubar.add_cascade(label="View", menu=view)
top.config(menu=menubar)
top.mainloop()
Thursday, February 11, 2021
pandas table with dictionary
df = pd.DataFrame(
{
"Name": [
"Braund, Mr. Owen Harris",
"Allen, Mr. William Henry",
"Bonnell, Miss. Elizabeth",
],
"Age": [22, 35, 58],
"Sex": ["male", "male", "female"],
}
)
print(df)
output:
Name Age Sex
0 Braund, Mr. Owen Harris 22 male
1 Allen, Mr. William Henry 35 male
2 Bonnell, Miss. Elizabeth 58 female
pandas in python
import pandas as pd
In [2]:
data = pd.read_csv("http://bit.ly/imdbratings")
In [3]:
data
Out[3]:
| star_rating | title | content_rating | genre | duration | actors_list | |
|---|---|---|---|---|---|---|
| 0 | 9.3 | The Shawshank Redemption | R | Crime | 142 | [u'Tim Robbins', u'Morgan Freeman', u'Bob Gunt... |
| 1 | 9.2 | The Godfather | R | Crime | 175 | [u'Marlon Brando', u'Al Pacino', u'James Caan'] |
| 2 | 9.1 | The Godfather: Part II | R | Crime | 200 | [u'Al Pacino', u'Robert De Niro', u'Robert Duv... |
| 3 | 9.0 | The Dark Knight | PG-13 | Action | 152 | [u'Christian Bale', u'Heath Ledger', u'Aaron E... |
| 4 | 8.9 | Pulp Fiction | R | Crime | 154 | [u'John Travolta', u'Uma Thurman', u'Samuel L.... |
| ... | ... | ... | ... | ... | ... | ... |
| 974 | 7.4 | Tootsie | PG | Comedy | 116 | [u'Dustin Hoffman', u'Jessica Lange', u'Teri G... |
| 975 | 7.4 | Back to the Future Part III | PG | Adventure | 118 | [u'Michael J. Fox', u'Christopher Lloyd', u'Ma... |
| 976 | 7.4 | Master and Commander: The Far Side of the World | PG-13 | Action | 138 | [u'Russell Crowe', u'Paul Bettany', u'Billy Bo... |
| 977 | 7.4 | Poltergeist | PG | Horror | 114 | [u'JoBeth Williams', u"Heather O'Rourke", u'Cr... |
| 978 | 7.4 | Wall Street | R | Crime | 126 | [u'Charlie Sheen', u'Michael Douglas', u'Tamar... |
979 rows × 6 columns
Subscribe to:
Posts (Atom)
-
1. Write a program to accept the integer value and print its table. Note: ...