Skip to content

Instantly share code, notes, and snippets.

View chaewonkong's full-sized avatar

chaewonkong chaewonkong

View GitHub Profile
@chaewonkong
chaewonkong / fibonacci.py
Last active December 6, 2017 08:01
Fibonacci Sequence: Getting integer input and prints nth fibonacci number as an output
#Fibonacci Sequence Study
#This program will find out 2 things:
#1)Whether the given number is in fibonacci sequence,
#2)If it is in the Fibonacci sequence, then shows the nth
n = int(input('Please enter an integer:'))
def fibo(n):
if n in [1,2]:
return 1
@chaewonkong
chaewonkong / rsp_game_redo.py
Last active November 26, 2017 08:13
Rocks Sissors Papers Game program with 'Try Again' for draw situation. After playing, it asks yes no question to play again or not.
#This is an python game of 'Rocks, Sissors, Papers'
#A User can compete with the computer by select one of 'r', 's', 'p', which indicates 'Rock', 'Sissor', and 'Paper'
#Computer, decides one of 'Rock', 'Sissor', 'Paper' as well, by using random.choice
#After playing one game, the program will ask you whether want to play another game or not.
import random
#Function that changes input of ['r', 's', 'p'] as output of ['Rock', 'Sissor', 'Paper']
def rsp_func(user):
if user == 'r':
@chaewonkong
chaewonkong / lotto.py
Last active November 29, 2017 08:38
Simple program that generates 6 sets of numbers in range(1, 46) for Lotto(Korea's the most popular lottery)
'''Random Number Generator for the Korean Lottery called "Lotto"
This program generates random numbers for Korea's the most popular lottery "Lotto"
In Korean Lotto, A buyer selects six sets of numbers, each of them is in range of 1 to 45(including 45)
This program generates six sets of numbers in range(1, 46): Meaning 1 to 45 are included.
'''
#Function for making 6 numbersets in range(1, 46). Random Sampling without REPLACEMENT.
import random
@chaewonkong
chaewonkong / FizzBuzz.py
Created November 29, 2017 08:33
FizzBuzz Program. Returns "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for multiples of 15. It requires input number from the User, then generates list of numbers.
"""FizzBuzz Program
The program will return "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for multiples of 15.
In Beginning, the program will require the user to give an input number(integer).
The input number will be used in making list of numbers.
The list of numbers are consist of integers from 1 to the input number.
Meaning: Range(1, input+1)
"""
#Get an input of an integer from the user.
@chaewonkong
chaewonkong / leapyear.py
Last active November 30, 2017 06:09
Leap Year Calculator: Gets input of year in number, then tells whether it is leap year or ordinary year
'''
Leap Year Calculator
If you put a year in number(like 1992 or 2000), the program will tell you whether it is leap year or not.
'''
#Get an year number as an input
year_input = int(input("Please enter a year that you want to know:"))
@chaewonkong
chaewonkong / subject.py
Last active December 7, 2017 06:25
Table Trainning
'''Array Practice
<Table of Scores>: For Students A, B, C, D, E
A B C D E
Math 49 79 20 100 80
Computer 43 59 85 30 90
Foreign Language 49 79 48 60 100
Who got the better-than-average score from at least two out of 3 subjects?
'''
@chaewonkong
chaewonkong / what_day.py
Last active December 7, 2017 06:33
What Day Calculator, get 8 digit numbers of yyyymmdd then prints what day is yyyymmdd.
'''What Day Calculator based on 8 digits (yyyymmdd)
Input of 8 digits(first four for year, next two for month, last two for day)
Output = the exact day (like "Monday" or "Saturday")
Remember, 0001 Jan 1st was Monday!
'''
#Get an input: first 4 digits for year, next 2 digits for month, last 2 digits for day.
#The input will be saved as a string
@chaewonkong
chaewonkong / inheritance.py
Created December 4, 2017 11:42
Training for Class and Inheritance
'''Class and inheritance
base class = SchoolMember
sub classes = Teacher, Student
'''
class SchoolMember:
'''Represents any school member.'''
def __init__(self, name, age):
self.name = name
@chaewonkong
chaewonkong / PrimeNumber_list.py
Last active December 7, 2017 07:21
How many prime numbers are there in the given list?
'''Prime number Distinguisher and Counter
In given list, how many prime numbers are there?
Given list = [ 2, 4, 8, 9, 11, 12, 13, 15, 17, 19, 22, 23, 25, 29]
'''
list = [2, 4, 8, 9, 11, 12, 13, 15, 17, 19, 22, 23, 25, 29]
#1. Let's distinguish what prime numbers do we have
prime_list = []
@chaewonkong
chaewonkong / palindrome.py
Created December 8, 2017 00:33
Palindrome Distinguisher
'''Palindrome Distinguisher
From the input, it automatically tells you whether the input was palindrome or not
It also inquire you if you want to play again.
'''
#Reverse the words of input
def reverse(text):
return text[::-1]