Skip to content

Commit f6daa4a

Browse files
committed
Python for Beginners
1 parent c7b7c8a commit f6daa4a

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
import random
7+
string = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?"
8+
#input your pasword len
9+
passlen = int(input())
10+
password = "".join(random.sample(string,passlen))
11+
print(password)
12+

beginners/start-end_text_matching.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
# Matching text at start and at the end
7+
filename = "personal.txt"
8+
print(filename.startswith("per")) # True
9+
print(filename.endswith(".docx")) # False
10+
print(filename.endswith(".txt")) # True

beginners/table_using_for_loop.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
num = int(input('Enter integer value '))
7+
print('\n\nTable of ',num,' is below')
8+
for i in range(10):
9+
i += 1
10+
print('\n \t',num,' x ',i,' = ',num*i)

beginners/tuple_unpacking.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
# Tuple Unpacking or Multiple assignment
7+
t1 = 5, 7, 9
8+
x, y, z = t1
9+
print(x, y, z, sep = ' | ') # sep use to separate values between |
10+
11+
x, y, _ = t1 # it means doesn't need the third value
12+
print(x, y, sep = ' | ')
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
""" This file is create and managed by Tahir Iqbal
2+
----------------------------------------------
3+
It can be use only for education purpose
4+
"""
5+
6+
# Value vs Reference type Functions
7+
8+
# Value Type
9+
print('*Value Type*')
10+
num = 100
11+
def change_num(n):
12+
n += 100
13+
print('Inner num : ', n)
14+
change_num(num)
15+
print('Outer num : ', num)
16+
17+
# Reference Type
18+
# List, Dictionary
19+
print('\n*Reference Type*')
20+
list_num = [1, 2, 3, 4, 5]
21+
dict_num = {'one': 1, 'two': 2, 'three': 3}
22+
def change(list, dict):
23+
del list[0]
24+
list[-1] = 55
25+
26+
del dict['one']
27+
dict['three'] = 33
28+
print('Applying Function')
29+
print('Inner List : ', list)
30+
print('Inner Dictionary : ', dict)
31+
32+
print('Before')
33+
print('Outer List : ', list_num)
34+
print('Outer Dictionary : ', dict_num)
35+
change(list=list_num, dict=dict_num)
36+
print('After Call')
37+
print('Outer List : ', list_num)
38+
print('Outer Dictionary : ', dict_num)

0 commit comments

Comments
 (0)