-
Notifications
You must be signed in to change notification settings - Fork 0
/
book_practice.py
172 lines (156 loc) · 3.69 KB
/
book_practice.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import random
def defaulter():
string='''
### ### ### ##
### ### ### ##
########## ### %%%%%%%%$$$$$$##
### #### ### ##
### #### ### ##
##
'''
print(string)
def test():
print("hello")
return 1
def ran():
s=['ali','junaid','hamza','Zain','samad']
s.sort()
for i in range(0,len(s)):
print("hello to",s[i].title(),"and you are invited:")
for i in s:
if i=='this':
s.remove(i)
for item in range(0,len(s)):
s[item]=s[item].title()
print(s)
def file(name_of_file):
name_of_file+='.txt'
other_file=open('abc.txt','w')
try:
with open(name_of_file) as file_obj:
for item in file_obj:
other_file.write(item)
except:
print(name_of_file+'file does not find by python::')
for j in range(0,10):
other_file.write('####\n')
print('end')
def make(string):
s_list=list()
s_list=string.split(' ')
print(s_list)
def fuzzbuzz():
total=0
for item in range(1,1000):
if item%3==0 and item%5==0:
total=total+item
elif item%3==0:
total=total+item
elif item%5==0:
total=total+item
else:
continue
print(total)
def dictr():
user_0 = {
'username': 'efermi',
'first': 'enrico',
'la':'laal'
}
user_1 = {
'username': 'efermi',
'first': ['item ','item2','item3'],
'la':'laal'
}
users = {
'aeinstein': {
'first': 'albert',
'last': 'einstein',
'location': 'princeton',
},
'mcurie': {
'first': 'marie',
'last': 'curie',
'location': 'paris',
},
}
empty={}
for item in range(0,3):
name=input("enter the name:")
phone=int(input("enter the phone number:"))
empty[name]=phone
for item,k in empty.items():
print(item,k)
#arr=[user_0,user_1]
#for k,i in user_1.items():
# print(k,i)
#for j in arr:
# print(j)
def palindrome(string):
reverse=string[::-1]
if reverse==string:
print("yes this is :")
else:
print('not a plaindrome')
def largest():
flag=0
number=0
for i in range(2,10000000):
if flag==1:
break
for j in range(1,15):
if i%j!=0:
break
if i%j==0 and j+1==15:
flag=1
number=i
break
print(number)
def sum():
sq=0
sq_1=0
dif=0
for i in range(0,100):
sq+=i*i
for j in range(0,100):
sq_1+=j
sq_1=sq_1*sq_1
dif=sq_1-sq
print(dif)
def th():
counter2=0
counter=0
for item in range(1,50):
counter=2
while counter<item/2:
if item%counter!=0:
print(item)
counter2+=1
if counter2==13:
print(item)
break
counter=counter+1
def finder():
c=1000
tmp=0
for item in range(10,1000):
for j in range(10,1000):
tmp=(item*item)+(j*j)
if tmp==c:
print("the a and b is:")
print(item,j)
return
defaulter()
s="You’ll often want to run through all entries in a list, performing the same"
#make(s)
s='10001'
bignum ='7316717653133062491'
#dictr()
#fuzzbuzz()
#palindrome(s)
#largest()
#sum()
#th()
#finder()
file_name=input("enter the file name:")
file(file_name)