filmov
tv
Python Tips and Tricks
![preview_player](https://i.ytimg.com/vi/QCqrwlQ4EAQ/maxresdefault.jpg)
Показать описание
THESE WILL SAVE YOU A CRAZY AMOUNT OF TIME!
In this video I go over different tips and tricks in python that are sure to save you a lot of time while programming. Python was created on the basis of all things that are wrong with other programming languages; this explains why this language has so many helpful tools. Most of the tips and tricks shown are specific to python.
List of Tips and Tricks:
#Python cool tricks
#1 - Enumerate
li = ['a', 'b', 'c', 'd']
for x in range(len(li)):
print(li[x])
for i, item in enumerate(li):
print(i, item)
#2 - String multiplication
s = "hello"
print(s+s+s+s)
print(s*4)
#3 - variable swap
a = 1
b = 3
temp = a
a = b
b = temp
a,b = b,a
#4 - variable assignment from list
a = [1,2,3]
x,y,z = a
#5 - help() function
help(len)
#5 - dir() function
dir(str)
#6 - list comprhension
li = [x for x in range(10) if x%2 == 0]
#7 - Sorted and reversed
li = ['hello', 'abc', 'abcd', 'goodbye', 'name', 'tim', 'tech']
reversed(li)
sorted(li)
sorted(L, key = len)
Want To Support This Channel?
Bitcoin: 1PbkAYLFaJBgjbKn2ptGyBz65xWN8hJgBU
Ethereum: 0xdd42dbbdba60f7163fc7a840e189474b6e8bfcad
Ripple: rD4arM9CVjQWqi8f1kxdpCgkCgEkqBgtud
Please leave a LIKE and SUBSCRIBE for more content!
Tags:
- Tech With Tim
- Coding
- Pygame
- Python Tutorials
- Python Tips and Tricks
- Python tips
- Python tricks
- Python tips and tricks for beginners
In this video I go over different tips and tricks in python that are sure to save you a lot of time while programming. Python was created on the basis of all things that are wrong with other programming languages; this explains why this language has so many helpful tools. Most of the tips and tricks shown are specific to python.
List of Tips and Tricks:
#Python cool tricks
#1 - Enumerate
li = ['a', 'b', 'c', 'd']
for x in range(len(li)):
print(li[x])
for i, item in enumerate(li):
print(i, item)
#2 - String multiplication
s = "hello"
print(s+s+s+s)
print(s*4)
#3 - variable swap
a = 1
b = 3
temp = a
a = b
b = temp
a,b = b,a
#4 - variable assignment from list
a = [1,2,3]
x,y,z = a
#5 - help() function
help(len)
#5 - dir() function
dir(str)
#6 - list comprhension
li = [x for x in range(10) if x%2 == 0]
#7 - Sorted and reversed
li = ['hello', 'abc', 'abcd', 'goodbye', 'name', 'tim', 'tech']
reversed(li)
sorted(li)
sorted(L, key = len)
Want To Support This Channel?
Bitcoin: 1PbkAYLFaJBgjbKn2ptGyBz65xWN8hJgBU
Ethereum: 0xdd42dbbdba60f7163fc7a840e189474b6e8bfcad
Ripple: rD4arM9CVjQWqi8f1kxdpCgkCgEkqBgtud
Please leave a LIKE and SUBSCRIBE for more content!
Tags:
- Tech With Tim
- Coding
- Pygame
- Python Tutorials
- Python Tips and Tricks
- Python tips
- Python tricks
- Python tips and tricks for beginners
Комментарии