Skip to content

Instantly share code, notes, and snippets.

View chaewonkong's full-sized avatar

chaewonkong chaewonkong

View GitHub Profile
@chaewonkong
chaewonkong / multi_line_input.py
Created December 11, 2017 14:57
Dealing with multi-line input by using EOFError
'''Dealing with Multi-line input
by using EOFError, unless the user press ctrl+d, the program will keep get inputs and store it in the list.
Finally the user press ctrl+d, all stored input in the list will printed line by line.
'''
contents = []
while True:
try:
line = input()
@chaewonkong
chaewonkong / multiply_maximum.py
Last active December 10, 2017 04:34
For 4 digits of input, split into two double digits of numbers, which makes multiply of each other the biggest
'''Multiply Maximazer
Get 4 numbers as an input. Split into two double digits number that generates the maximum number
when they are multiplied by each other
'''
def Multiply_Max(numbers):
'''Sort the list reverse. Use indexing and make two double digits numbers a,b.
The biggest number and the smallest number should be accompanied wheareas, middle 2 numbers should also be accompanied
In order to calculate a*b, both a, b should be integers. change all the indexed to int.
@chaewonkong
chaewonkong / caesar_cypher.py
Last active December 10, 2017 03:13
Caesar Cypher Encoder/Decoder
'''Caesar Cypher encoder/decoder
From input, this program will generate Caesar cypher(each alphabets of input will be changed 3 step forward alphabets
in alphabet order. It will print the outcome.
Then, the program will decode the generated Caesar cypher and print it.
The user can compare her/his original input to the printed outcome.
'''
@chaewonkong
chaewonkong / class_inheritance.py
Created December 9, 2017 09:29
Class and inheritance
#General Features about computers
class Computer:
def __init__(self, model, cpu, ram, storage, os):
self.model = model
self.cpu = cpu
self.ram = ram
self.storage = storage
self.os = os
#Function that tell the features line by line
@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]
@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 / 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 / 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 / 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 / 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:"))