-
Notifications
You must be signed in to change notification settings - Fork 1
/
day 13.py
97 lines (81 loc) · 1.83 KB
/
day 13.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pattern 1
num=int(input("enter the number :"))
for i in range(1,num+1):
print(i*i)
#pattern {floyds triangle}
num=int(input("enter a number :"))
k=1
for i in range(1,num+1):
for j in range(1,i+1):
print(k,end =" ")
k=k+1
print()
#pattern 2
num=int(input("enter a number :"))
k=1
for i in range(1,num+1):
for j in range(1,i+k):
print(j,end=" ")
k=k+1
print()
#pattern 2
num=int(input("enter a number :"))
for i in range(1,num+1,-1):
for j in range(i):
print(i,end=" ")
print()
#pattern 2
num=int(input("enter a number :"))
for i in range(num,0,-1):
for j in range(i,0,-1):
print(j,end=" ")
print()
#int to string conversion
a=input("enter the number :").split()
for i in range(len(a)):
a[i]=int(a[i])
print(a)
#length of list
length=int(input("enter the length : "))
b=[]
for i in range(length):
a=int(input("enter the number : "))
b.append(a)
print(b)
#unpacking arguments
def add(*arg):
sum1=0
for i in a:
sum1=sum1+i
return(10,203,4040)
#unpacking argument for dictionary
def dicn(**kwarg):
for i,j in dict.items(kwarg):
print(i,j)
dicn(a='apple',b='ball',c='cat')
#pyramid traingle
#upper
n=int(input("enter the number :"))
for i in range(1,n+1):
for j in range(i):
print(i,end=" ")
print()
#lower
for i in range(n-1,0,-1):
for j in range(i,0,-1):
print(i,end=" ")
print()
#paranthesis checking
num=input("enter value : ")
list1 = ["[","{","("]
list2 = ["]","}",")"]
j=1
for i in range(len(num)//2):
if num[i] in list1:
if list2[list1.index(num[i])]!=num[-j]:
print("invalid")
break
else:
j=j+1
else:
print("valid")