#PYTHON(DAY44)
Example Programs
1) Python Program to Create Pyramid Patterns
rows = int(input('enter your rows:'))
for i in range(rows):
for j in range(i+1):
print('*',end = " ")
print("\n")
And the output is:
*
* *
* * *
* * * *
* * * * *
2) Python Program to Merge Two Dictionaries
dict_1 = {1:'a',2:'b'}
dict_2 = {2:'c',4:'d'}
dict_3 = dict_2.copy()
dict_3.update(dict_1)
print(dict_3)
And the output is:
{2: 'b', 4: 'd', 1: 'a'}
3) Python Program to Access Index of a List Using for Loop
my_list = [11,22,33]
for index in range(len(my_list)):
value = my_list[index]
print(index,value)
And the output is:
0 21
1 44
2 35
3 11
No comments:
Post a Comment