Here are some cool tips and tricks which is used while making a project or program.
10. Adding 2 list :
for this you just have to create 2 list and then combine them in 2 variables. i.e. a=[1,2,3] b=[4,5,6] then c=a+b. Now c can hold 2 list.
In this trick you can print calendar according to calendar format like import calendar then print calendar.month(2017,1) you can also pass variable to it according to your format.
In other languages you have to write multiple lines of code for it but in Python you can just do it by single line i.e a,b=b,a that's the beauty of python.
In python you can convert any string into list by using list function i.e a='abcd' then a=list(a). If your list contains integer values then just convert it by using str() function i.e a=123 then a=str(a) now you can convert it into list.
You can join list elements by using join function i.e. ''.join(msg) also if you pass any value within '' then it join with all elements.
5: Date Time:
This is the essential thing for programmer to show it any project or program just import datetime module and call the function and print it (by watching the video) also you can change the format of it %d for date, %m for month, %y for year, %I for hour, %M for minute, %s for second, %p for 12 hour.
4. Random :
using random function is essential in making games, cryptography,projects etc , in python import random module and select your random value via random.choice(variable). You can also select list or any type of value.
3: Color :
A program can become more attractive if it has a beautiful color in it. Just import os module and put os.system('color A') and set color according to you.
Color code in os are:
9: light blue
A: light green
B: light aqua
C: light red
D: light purple
E: light yellow
F: Bright white
Sometimes you have to compress your messages or values in your program, by python you can do it eaisly, Just import zlib module and pass your message in zlib.compress(msg), it compress your msg, to decompress just use zlib.decompress(msg) to decompress it.
1: Message Box:
To make a program user friendly, this is very useful, just import ctypes and write ctypes.windll.user32.MessageBoxA(0,'Your Message','Message title',0) here 0 is for ok button. You can also use tkinter but i like this though.
So guys that's all in this video. Hope you like it .
Thumbs up if you like it and subscribe to get more new stuff.