Skip to content

Instantly share code, notes, and snippets.

@yonghanjung
Last active July 22, 2022 13:11
Show Gist options
  • Save yonghanjung/b5f87fbd329fa4527388 to your computer and use it in GitHub Desktop.
Save yonghanjung/b5f87fbd329fa4527388 to your computer and use it in GitHub Desktop.
def main():
for i in range(1,11):
print 2*i
if __name__ == '__main__' :
main()
def main():
for i in range(5):
print ' '*(4-i),
print '*'*(i+1)
if __name__ == '__main__':
main()
def main():
a = input()
for i in range(a+1):
print ' ' * (a-i),
print '*' * (i+1)
if __name__ == '__main__':
main()
import random
def main():
balls = range(1,46)
random.shuffle(balls)
print sorted(balls[0:6])
if __name__ == '__main__':
main()
from random import shuffle
def main():
x = [[i] for i in range(45)]
shuffle(x)
print x[0:6]
if __name__ == '__main__':
main()
def main():
a = ['Python is a programming language', 'that lets you work quickly', 'and integrate systems more effectively']
a = ''.join(a)
print a.split()
if __name__ == '__main__':
main()
def main():
a = ['Python is a programming language', 'that lets you work quickly', 'and integrate systems more effectively']
a = ''.join(a)
a = a.split()
for i in a:
print i
if __name__ == '__main__':
main()
def main():
a = ['Python is a programming language', 'that lets you work quickly', 'and integrate systems more effectively']
for i in ' '.join(a).split(): print i
if __name__ == '__main__':
main()
import datetime
def main():
today = datetime.datetime.now()
a = str(today)[:-7]
print "[",a,"]"
if __name__ == '__main__':
main()
from collections import Counter
def countWords(a_list):
words = {}
for i in range(len(a_list)):
item = a_list[i]
count = a_list.count(item)
words[item] = count
return sorted(words.items(), key = lambda item: item[1], reverse=True)
def main():
a = "To find the frequency of these items its easier then you guys are making it. if you have all the words in a list (which is easy to do using the string split function). Then:"
print countWords(a.split())
if __name__ == "__main__":
main()
def main():
a = "This question has been asked before and already has an answer. If those answers do not fully address your question, please ..."
a = a.split()
for i in a:
print i, "=", a.count(i)
if __name__ == "__main__" :
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment