Python Cheet Sheet
Python Cheet Sheet
def main():
number_of_students = 10
input_data(number_of_students)
main()
10 fake Names and Countries in Hindi language
from faker import Faker
fake = Faker('hi_IN') #'hi_IN' changed the language
for i in range(0, 10):
print('Name->', fake.name(), ', ', fake.country())
https://faker.readthedocs.io/en/master/
ar_EG - Arabic (Egypt) hr_HR - Croatian
ar_PS - Arabic (Palestine) hu_HU - Hungarian Language
ar_SA - Arabic (Saudi Arabia) hy_AM - Armenian and
it_IT - Italian
bg_BG - Bulgarian Country
ja_JP - Japanese
bs_BA - Bosnian Codes
ka_GE - Georgian (Georgia)
cs_CZ - Czech ko_KR - Korean
de_DE - German lt_LT - Lithuanian
dk_DK - Danish lv_LV - Latvian
el_GR - Greek ne_NP - Nepali
en_AU - English (Australia) nl_NL - Dutch (Netherlands)
en_CA - English (Canada) no_NO - Norwegian
en_GB - English (Great Britain) pl_PL - Polish
pt_BR - Portuguese (Brazil)
en_NZ - English (New Zealand)
pt_PT - Portuguese (Portugal)
en_US - English (United States)
ro_RO - Romanian
es_ES - Spanish (Spain) ru_RU - Russian
es_MX - Spanish (Mexico) sl_SI - Slovene
et_EE - Estonian sv_SE - Swedish
fa_IR - Persian (Iran) tr_TR - Turkish
fi_FI - Finnish uk_UA - Ukrainian
fr_FR - French zh_CN - Chinese (China)
hi_IN - Hindi zh_TW - Chinese (Taiwan)
Create Fake Profiles
print (fake.credit_card_full(card_type=None))
window = tkinter.Tk()
window.title("Welcome to All")
window.mainloop()
Create a label widget
import tkinter
window = tkinter.Tk()
window.title("Welcome")
lbl = tkinter.Label(window, text="Hello")
lbl.grid(column=0, row=0)
window.mainloop()
window.mainloop()
Assorted Buttons
import tkinter
parent = tkinter.Tk()
redbutton = tkinter.Button(parent, text = "Red", fg = "red")
redbutton.pack( side = tkinter.LEFT)
greenbutton = tkinter.Button(parent, text = "Black", fg = "black")
greenbutton.pack( side = tkinter.RIGHT )
bluebutton = tkinter.Button(parent, text = "Blue", fg = "blue")
bluebutton.pack( side = tkinter.TOP )
blackbutton = tkinter.Button(parent, text = "Green", fg = "red")
blackbutton.pack( side = tkinter.BOTTOM)
parent.mainloop()
Multi-Window Interface
import tkinter
window = tkinter.Tk()
window.title("Welcome")
window.geometry('350x200')
def showmessage():
def window2destroy():
window2.destroy()
window2 = tkinter.Tk()
window2.title("Welcome")
window2.geometry('100x100')
btn2 = tkinter.Button(window2, text="Exit", command=window2destroy)
btn2.grid(column=1, row=0)
def clicked():
lbl.configure(text="Button was clicked !!")
def clickhere():
getg2=g2.get()
r.config(text=getg2)
g2=tk.IntVar()
r=tk.Label(root, text=“Output”)
r.grid(row=3, column=0)
def clickhere():
gp=grosspay.get()
deduc=deductions.get()
taxable=gp-deduc
taxablelabel.config(text=taxable)
grosspay=tk.IntVar()
deductions=tk.IntVar()
taxablelabel=tk.Label(root)
taxablelabel.grid(row=3, column=0)
root.mainloop()
import tkinter as tk
from functools import partial
root = tk.Tk()
root.geometry('400x200+100+200')
root.title('Calculator')
number1 = tk.StringVar() Calculations
number2 = tk.StringVar()
labelNum1 = tk.Label(root, text="A").grid(row=1, column=0) on User
labelNum2 = tk.Label(root, text="B").grid(row=2, column=0)
labelResult = tk.Label(root) Inputs
labelResult.grid(row=7, column=2)
https://www.fast2sms.com
Create Account
And
Click on
DEV API
Click Here for Code
Select Programming Language
Python Code with API
import requests
url = "https://www.fast2sms.com/dev/bulk"
payload =
"sender_id=FSTSMS&message=This%20is%20a%20test%20message&langua
ge=english&route=p&numbers=9034001978"
headers = {
'authorization': “API-KEY",
'Content-Type': "application/x-www-form-urlencoded",
'Cache-Control': "no-cache",
}
print(response.text)
GAURAV KUMAR
E-mail : [email protected]
http://www.gauravkumarindia.com