This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "http://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture" | |
r = requests.get(url) | |
soup = BeautifulSoup(r.text,"html5lib") | |
for content in soup.find_all(class_="content-section"): | |
for para in content.find_all('p'): | |
for child in para.descendants: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "http://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture" | |
r = requests.get(url) | |
open_file = open('file.txt','w') | |
soup = BeautifulSoup(r.text,"html5lib") | |
for content in soup.find_all(class_="content-section"): | |
for para in content.find_all('p'): | |
for child in para.descendants: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = input() | |
s = s.upper() | |
lens = len(s) | |
consonants = set() | |
vowels = set() | |
unique = [] | |
substrings = [] | |
stuart = [] | |
kevin = [] | |
kevintot,stuarttot = 0,0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Final 4""" | |
pbook = {} | |
search=[] | |
for x in range(int(input())): | |
a = input().strip().split(' ') | |
pbook[str(a[0])]=int(a[1]) | |
s=True | |
while s: | |
s=input() | |
search.append(str(s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Solved""" | |
def ispallindrome(arr,s,temp): | |
for i in arr: | |
temp -= 1 | |
s.append((arr[temp])) | |
s = "".join(s) | |
arr = "".join(arr) | |
if s==arr: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Final Parital""" | |
"""Requires Python 3""" | |
def ingFrom(s): | |
for x in s: | |
li.append(x) | |
if li[len(li)-1]=='e' and li[len(li)-2]!='i': | |
del li[len(li)-1] | |
li.append("ing") | |
elif li[len(li)-1]=='e' and li[len(li)-2]=='i': | |
del li[len(li)-1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Solution""" | |
def vowOrNot(c): | |
c = c.upper() | |
if c in 'AEIOU': | |
return True | |
else: | |
return False | |
print(vowOrNot(input('Enter character to check if Vowel or not'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Solved""" | |
"""https://www.hackerrank.com/challenges/list-comprehensions""" | |
x = int(input()) | |
y = int(input()) | |
z = int(input()) | |
n = int(input()) | |
temp = [] | |
lis = [] | |
for i in range(x+1): | |
for j in range(y+1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Solved""" | |
ls = [] | |
n = int(input()) | |
for x in range(n): | |
arr = [arr_temp for arr_temp in input().strip().split(' ')] | |
ls.append(arr) | |
s = input() | |
for i in range(len(ls)): | |
for j in ls[i]: | |
if j==s: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
temp = [20.0, 20.0, 19.0, 19.0, 21.0] | |
works = [37.21,37.21,37.2,41,39] | |
def second_smallest(numbers): | |
m1, m2 = float('inf'), float('inf') | |
for x in numbers: | |
if x <= m1: | |
m1, m2 = x, m1 | |
elif x < m2: | |
m2 = x | |
return m2 sd |