Last active
July 22, 2022 13:11
-
-
Save yonghanjung/b5f87fbd329fa4527388 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def main(): | |
for i in range(1,11): | |
print 2*i | |
if __name__ == '__main__' : | |
main() |
This file contains hidden or 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
def main(): | |
for i in range(5): | |
print ' '*(4-i), | |
print '*'*(i+1) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
def main(): | |
a = input() | |
for i in range(a+1): | |
print ' ' * (a-i), | |
print '*' * (i+1) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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 random | |
def main(): | |
balls = range(1,46) | |
random.shuffle(balls) | |
print sorted(balls[0:6]) | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
from random import shuffle | |
def main(): | |
x = [[i] for i in range(45)] | |
shuffle(x) | |
print x[0:6] | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
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() |
This file contains hidden or 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
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() |
This file contains hidden or 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
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() |
This file contains hidden or 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 datetime | |
def main(): | |
today = datetime.datetime.now() | |
a = str(today)[:-7] | |
print "[",a,"]" | |
if __name__ == '__main__': | |
main() |
This file contains hidden or 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
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() |
This file contains hidden or 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
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