Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
@abhinavkorpal
abhinavkorpal / gist:5eaaee2ec0e3861cf761d88ccc9cf7ec
Created April 17, 2017 10:53
Installing Jenkins on Ubuntu
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
def wrap(string, max_width):
return textwrap.fill(string,max_width)
#Replace all ______ with rjust, ljust or center.
thickness = int(raw_input()) #This must be an odd number
c = 'H'
#Top Cone
for i in range(thickness):
print (c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1)
#Top Pillars
@abhinavkorpal
abhinavkorpal / string_validators.py
Created April 11, 2017 13:39
String Validators
if __name__ == '__main__':
s = raw_input()
print any(c.isalnum() for c in s)
print any(c.isalpha() for c in s)
print any(c.isdigit() for c in s)
print any(c.islower() for c in s)
print any(c.isupper() for c in s)
@abhinavkorpal
abhinavkorpal / string.py
Created April 11, 2017 06:25
Find a string
def count_substring(string, sub_string):
count = 0
for i in range(len(string)-len(sub_string)+1):
if(string[i:i+len(sub_string)]==sub_string):
count += 1
return count
def mutate_string(string, position, character):
l = list(string)
l[position] = c
return "".join(l)
def print_full_name(a, b):
print "Hello {0} {1}! You just delved into python.".format(a, b)
@abhinavkorpal
abhinavkorpal / split _and_join.py
Created April 11, 2017 05:20
String Split and Join
def split_and_join(line):
# write your code here
return("-".join(line.split()))
@abhinavkorpal
abhinavkorpal / swap.py
Created April 11, 2017 05:03
sWAP cASE
def swap_case(s):
return s.swapcase()
@abhinavkorpal
abhinavkorpal / percentage.py
Created April 8, 2017 07:57
Finding the percentage
n = int(raw_input())
mydict = {}
for line in range(n):
info = raw_input().split(" ")
score = map(float, info[1:])
mydict[info[0]] = sum(score) / float(len(score))
print "%.2f" % round(mydict[raw_input()],2)