-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
214 lines (161 loc) · 4.14 KB
/
Copy pathtest.py
File metadata and controls
214 lines (161 loc) · 4.14 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#test
#from ctypes.wintypes import PINT
try:
import time
import random
import csv
import pygame
import requests
import json
except:
print('')
apiCall = requests.get('https://api.openweathermap.org/data/2.5/weather?lat=42.82642299955682&lon=-71.57923160207767&units=imperial&appid=15dfa1324b44123c1634401424dd71a1')
print('code:', apiCall.status_code)
apiJson = apiCall.text
data = json.loads(apiJson)
print(data['name'])
print(data)
'''
numm = input('pick a number\n')
numm = int(numm)
#proper setup for a try&except in a loop
while True:
num = input('pick a number \n')
try:
if(float(num) == 1):
print('cool')
break
except:
print('i said a number dummy :3')
#0 in the minimum and 55 is max, it will add the -5 to i every loop and will only run the code when i is in that range
for numm in range(0,int(numm)+1,5):
print(numm)
'''
#while True:
#print(random.randint(1,20))
'''
num = input("Enter any number to test whether it is odd or even:\n")
if (int(num) % 2)==0:
print("The number is even")
else:
print("The provided number is odd")
numlist = [1, 2, 3, 4, 5, 6, 7, 100, 110, 21, 33, 32, 2, 4, 13]
for x in numlist:
print(x)
word = 'banana'
count = 0
for letter in word:
if letter == 'a':
count = count + 1
print(count)
print("Fake Python".replace("Fake", "Real"))
print("Yes or no?")
answer = input(' > ')
if(answer.lower() == 'yes'):
print('pog')
else:
print('cringe')
word_file = open("scrabble_wds.txt")
word = 'abandoning'
for line in word_file:
if(line.find(word) != -1):
print('pog')
break
else:
print('cringe')
print('end')
for line in fhand:
line = line.rstrip()
if line.find('aah') == -1: continue
print(line)
fhand = open('scrabble_wds.txt')
linee = fhand.read()
word = input('word?\n')
word = word.lower()
print(word)
if word in linee:
print('pog')
# open the file in read mode
filename = open('peoples.csv', 'r')
# creating dictreader object
file = csv.DictReader(filename)
# creating empty lists
people = []
# iterating over each row and append
# values to empty list
for col in file:
people.append(col['Goat'])
# printing lists
#print('People:', people)
try:
fhand = open('Abe_Lincoln_speech.txt')
except:
print('File cannot be opened:')
exit()
counts = dict()
for line in fhand:
words = line.split()
for word in words:
if word not in counts:
counts[word] = 1
else:
counts[word] += 1
fin_max = max(counts, key=counts.get)
thing = counts.get(fin_max)
print(thing)
print("Maximum value:",fin_max)
word = input('>')
def reverse(s):
str = ""
for i in s:
str = i + str
return str
palindrome = word + reverse(word)
print(palindrome)
# Program to check if a number is prime or not
example = 29
# To take input from the user
#num = int(input("Enter a number: "))
numlist = [611,612,613,617,73,77,79,5403,5402,5407,669,1188,1189]
def primeNumCheck(num):
flag = False
if num == 1:
flag = False
elif num > 1:
# check for factors
for i in range(2, num):
if (num % i) == 0:
# if factor is found, set flag to True
flag = True
# break out of loop
break
return flag
for num in numlist:
if(primeNumCheck(num)):
print(num, "is a prime number")
else:
print(num, 'is not a prime number')
print("I am sorting people by age. Enter your age.")
#added a try around the age input to ensure a usable number
while True:
try:
age = input(" > ")
age = int(age)
break
except:
print('age needs to be a whole number')
#the numbers being compaired were in quoat marks so they were strings not INTs
if age < 13:
print("kid")
elif age < 20:
print("teen")
else:
print("adult")
numm = input('>')
#0 in the minimum and 55 is max, it will add the -5 to i every loop and will only run the code when i is in that range
for numm in range(int(numm),0,-1):
print(numm)
'''
def testThing():
print('test')
#print('hello world')