Repository navigation
Expand file tree
/
Copy pathpy_4.py
More file actions
67 lines (53 loc) · 1.86 KB
/
Copy pathpy_4.py
File metadata and controls
67 lines (53 loc) · 1.86 KB
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
# name="prashant"
# newname=" "
# for i in name:
# if i not in name:
# newname+=i
# print(name)
# print(newname)
# mycart=[10,20,30,200,800,60,700]
# for i in mycart: #i=0,1,2,3,4,5,6:10,20,30,200,800,60,700
# if i>400:
# print("this is mycart purchased item")
# continue
# print(i)
#wap to check if a given string id palindrome
# name="racecar"
# if name==name[::-1]:
# print("palindrome")
# else:
# print("not")
#wap to check if two strings are anagrams of each other input:"silent,listen" output:anagram
# name="silent"
# if name==name[::-1]:
# print("anagram")
# else:
# print("not")
# Add key value pairs to a dictionary:wap to add key-value pairs to dictionary
# uuse square brskects or the update()method
# i/p:
# remove key value pairs from dictionary
# use pop to delete method
# i/p:{"name","alice","age",30}key:"age"
# o/p: {"name":"alice"}
# check if key exists in dictionary:
# use operator or get()method
# i/p:{"name:","alice",""}
# # v
# #NESTED FOR LOOP 1 2 3
# for i in range(1,4): #outer loop=>rows
# > 1 1 1 1
# for j in range(1,4): #inner loop=>column 2 2 2 2
# 3 3 3 3
# print(i, end=" ") (i,j)=1,1
# print()
n=int(input("enter no in rows:"))
for i in range(1,n+1):
for j in range (1,n+1):
print(chr(64+i),end=" ")
print()
n=int(input("enter no in rows:"))
for i in range(1,n+1):
for j in range (1,n+2-i):
print("*", end=" ")
print()