카카오 오븐을 활용하여 UI 설계를 진행했습니다. 

카카오 오븐은 카카오의 베타 서비스로 간단한 UI를 구현하고자 할 때 편리한 서비스라고 할 수 있습니다. 

이를 활용하여 Client 요구사항을 반영한 UI를 설계해보았습니다. 

1차 UI 설계를 기준으로 더할 기능과 뺄 기능에 대해 회의를 통하여 자세히 논의할 계획입니다. 

 

구현한 페이지는 오른쪽 상단에 코드를 만들어 Client 요구사항 표를 보면서 바로 해당 UI를 찾을 수 있도록 하였습니다. 구현한 화면은 모두 40개 정도 되므로 이 중 중심이 되는 기능들만 게시하도록 하겠습니다. 

 

메인

모임 카테고리

Q&A / Contact form

팀소개

마이페이지 - 내 모임

모임상세정보

이벤트 상세정보

if

Since there are no brackets like in Java, indentation is very important in the if statement. 

In the example below, you must convert the string type 'n' to an integer

n = input('Insert an integer.')
print(type(n))             
n = int(n)                 

if n>=0 :
    print(n, 'is a positive number.')

if n<0:
    print(n, 'is a negative number.')

if ~ else with try~ except

try:
    n = int(input('Insert an integer.'))
    
    if n >= 0:
        print(n, 'is a positive number.')
    else:
        print(n, 'is a negative number.')
    
except:
    print('Please insert numbers only.')

if ~ elif ~ else

In Java, there is else if, whereas in Python it is elif. 

s = int(input('Insert your score.'))

if s >= 90:
    print('A')
elif s >= 80:
    print('B')
elif s >= 70:
    print('C')
elif s >= 60:
    print('C')
else:
    print('F')

 

Loops: for / while 

There is no do ~ while statement in Python. Usually for loops are used a lot.

for loop

for loops are many times used with range() built-in function.

Please refer to my last post if you want to know more about the range() function.

링크

Example1

for i in range(10):             # 0 ~ 9
    print(i+1, 'Cofee and Tea')

for i in range(1, 11):          # 1 ~ 10
    print(i, 'Love in Life')
    
for i in range(1, 11, 1):       # 1 ~ 10   
    print(i, 'Happy days')

Example2 

for i in range(1, 10, 2):
    print(i, end=' ')                   # 1 3 5 7 9
print()

for i in range(1, 10):                  # 1 ~ 9
    print(i, end=' ')                   # 1 2 3 4 5 6 7 8 9
print()

for i in range(10):                     # 0 ~ 9
    print(i, end=' ')                   # 0 1 2 3 4 5 6 7 8 9
print()

for i in range(10, 1, -1):
    print(i, end=' ')                   # 10 9 8 7 6 5 4 3 2

Example3

sum = 0
for i in range(1, 11):              #  1 ~ 10
    sum = sum + i                   # sum += i
    print('1~',i,'=',sum)

print('sum=', sum)

Example4

# Sum of odd numbers
odd = 0
for i in range(1, 101, 2):
    odd += i
print(odd)

# sum of even numbers
even = 0
for i in range(0, 101, 2):
    even += i
print(even);

Example5

It is the same result as Example4, but it is a simpler way with just one for loop. 

odd = even = 0
for i in range(1, 101):                 # 1 ~ 100
    if i%2 == 0:                        # Even 
        even += i
    else:                               # Odd
        odd += i
print('1~100 sum of odd numbers:', odd)
print('1~100 sum of even numbers:', even)

Example6

#Multiplication table with a format() function.

dan = int(input('Insert a number between 1 and 9.'))

print('[',dan,'Table ]')
for i in range(1, 10):              # 1 ~ 9
    # print(dan, '*', i, '=', dan * i)
    print('{0} * {1} = {2}'.format(dan, i, dan*i))

Example7 

for loop with list

# List
list = ['China', 'Canada', 'Egypt', 'South Korea', 'France']
print(type(list))              # <class 'list'>
print(list)                    # ['China', 'Canada', 'Egypt', 'South Korea', 'France']
print(list[0])                 # China

for i in list:
    print(i, end=' ')           # China Canada Egypt South Korea France
print()

for loop with tuple

#Tuple
t = ('red','orange','yellow','green','blue','navy','purple')
print(type(t))                  # <class 'tuple'>
print(t)                        # ('red', 'orange', 'yellow', 'green', 'blue', 'navy', 'purple')
print(t[0])                     # red

for i in t:
    print(i, end=' ')           # red orange yellow green blue navy purple
print()

for loop with dictionary

# Dictionary : { 'key' : 'value' }
dic = {'Apple' : 'http://www.apple.com',
       'Google' : 'http://www.google.com',
       'Naver' : 'http://www.naver.com'}

print(type(dic))                # <class 'dict'>
print(dic)                      # {'Apple': 'http://www.apple.com', 'Google': 'http://www.google.com', '네이버': 'http://www.naver.com'}
print(dic['Apple'])             # http://www.apple.com

for k, v in dic.items():
    print(k,':', v)

while loop

while loop is very similar to Java.

Example1 

i = 1                          
while i <= 10 :                
    print(i,'I love Python')           
    i += 1

Example2

i=1; odd=even=0                
while i <= 100:                # Condition
    if i%2 == 0:                # Even numbers
        even += i
    else:                       # Odd numbers
        odd += i
    i += 1                      

print('1~100 sum of odd numbers:',  odd)
print('1~100 sum of even numbers:',  even)

Example3

Multiplication table with format function.

dan = int(input('Insert a number between 1 to 9'))

i = 1                                  
while  i <= 9:                          
    # print(dan, '*', i, '=', dan*i)
    print('{0} * {1} = {2}'.format(dan, i, dan*i))
    i += 1

Example4

Multiplication table

dan=2                                     
while dan <= 9:                             
    print('[',dan,'Table ]')
    i = 1
    while i <= 9:                           
        print(dan, '*', i, '=', dan*i)
        i += 1                              
    dan += 1                              
    print()

break and continue

Infinite loop 

i=1
while True:

    print(i, 'Infinite loop')
    i += 1

Infinite loop with break

i=1
while True:

    print(i, 'Infinite loop')
    if i == 100: break
    i += 1

for, if, and break

for i in range(1, 1001):            # 1 ~ 1000
    print(i,'Print')

    if i==100:
        print('Loop Escaped')
        break

continue

continue is for going back to the loop. 

Example1 

for i in range(1, 11):              # 1 ~ 10

    if i==5:
        continue
    print(i, 'Print')

Example2 

If it is not divided into 5, it skips printing.

for i in range(1, 101):             # 1 ~ 100

    if i%5 != 0:                    
        continue
    print(i)

'Python' 카테고리의 다른 글

Python) try: except:  (0) 2022.11.14
Python) list  (0) 2022.11.08
Python) Dictionary  (0) 2022.11.04
Python) Tuple / Set  (0) 2022.11.03
Python) Datatypes - Str  (0) 2022.11.03

GitHub is a necessary tool when you cooperate with other people on a project. This post will introduce how to use GitHub and configure the git repository in STS/Eclipse. STS and Eclipse are very similar to each other so I will demonstrate STS. 

 

This is how Git works and soon, we will be more familiar with the local repository and remote repository. 

First, you need to have your account in GitHub. As I already have one, I will sign in on GitHub.

Click the settings.

 

Go to Developer settings and create Tokens(Classic). We will use these tokens when we connect our repository to the local in STS / Eclipse. 

To clone the repository, copy the HTTPS for pasting in STS / Eclipse.

In a show view, make Git Repository visible and clone the git repository source by pasting the HTTPS and the tokens in the location and Authentication. The user is the email ID that you use to log in to GitHub.

 

After the creation, you will see this Git Repositories tap.

Right Click the Working Tree folder. By clicking Import Projects you can import the remote repository to the local. 

To connect, right-click the project and go to Team - Share Project.

After connecting it, you will see the new options when you go to Team. Among them, click Commit

You can upload the edited files in the Git Staging that will pop up. The repository has something changed to re-upload and Commit Message to attach. 

There are two buttons, Commit and push for uploading to the local and the remote repository, whereas, Commit is only for the local repository.

To see the updated repository on GitHub, click Commit and Push

 

 

After clicking Next and Finish buttons, you will see this on your GitHub.

 

Now, let us try creating a new branch in STS. In the group project, each group member needs to create their branch and work in the branch. 

Right click - Team - Switch To - New Branch

Write the new branch name. 

So, when you do the project with your colleagues, you will see a lot of this alert on GitHub.

About the button Compare & pull request, there is a tap on Github. To merge the branches, click New pull request.

Choose the base and compare and click Create pull request.

Again, after writing some comments, click Create pull request.

After checking if there is any conflicts with the base branch, you can Merge pull request.

if you see this message, it means the "success"!

'Git & GitHub' 카테고리의 다른 글

GitHub) SourceTree  (0) 2022.11.12

Str, List and Dictionary are the most used data structure. 

To save data in a dictionary, you must save the key and value(data) together, and you will use the key to get the value. Like set, dictionary is not an ordered data structure as well. If there are multiple overlapped key and we search the same key, it will print out the value of the last key.

Example

{ 'key ' : 'value' } = { 'Name' : code }
names = {'Mary':10999, 'Sams':2111, 'Amy':9778, 'Tom':20245 , 'Mike':27115,
         'Bob':5887, 'Kelly':7855, 'Mary':100}
print(type(names))           # <class 'dict'>
print(names)                 # {'Mary': 100, 'Sams': 2111, 'Amy': 9778, 'Tom': 20245, 'Mike': 27115, 'Bob': 5887, 'Kelly': 7855}

print(names['Amy'])        # 9778
print(names['Tom'])         # 20245
print(names['Mary'])        # 100

keys()

names = {'Mary':10999, 'Sams':2111, 'Amy':9778, 'Tom':20245 , 'Mike':27115,
         'Bob':5887, 'Kelly':7855}

for k in names.keys():
    # print('Key:%s\t Value:%d'%(k, names[k]))
    # print('Key:', k, ' Value:', names[k])
    print('Key:{0} Value:{1}'.format(k, names[k]))

values()

result = names.values()
print(type(result))               # <class 'dict_values'>
print(result)                     # dict_values([10999, 2111, 9778, 20245, 27115, 5887, 7855])

list = list(result)              # list()
print(type(list))                # <class 'list'>
print(list)                      # [10999, 2111, 9778, 20245, 27115, 5887, 7855]

count()

count = sum(list)
print('Sum:%d'%count)

items()

for item in names.items():
    print(item)                 # ('Mary', 10999)
                                # ('Sams', 2111)
                                # ...

for k, v in names.items():
    print(k,':',v)              # Mary : 10999
                                # Sams : 2111
                                # ...

To edit dictionary values

names = {'Mary':10999, 'Sams':2111, 'Aimy':9778, 'Tom':20245 , 'Michale':27115,
         'Bob':5887, 'Kelly':7855}

print(names)
print(names['Aimy'])            # 9778
print(names.get('Aimy'))        # 9778

names['Aimy'] = 10000

print(names['Aimy'])            # 10000

To delete dictionary values

names = {'Mary':10999, 'Sams':2111, 'Aimy':9778, 'Tom':20245 , 'Michale':27115,
         'Bob':5887, 'Kelly':7855}

del names['Sams']
del names['Bob']

# To check
print(names)

# Delete all
names.clear()

# To check
print(names)            # {}

mydic = {}

Example

names = {'Mary':10999, 'Sams':2111, 'Aimy':9778, 'Tom':20245 , 'Michale':27115,
         'Bob':5887, 'Kelly':7855}

k = input('Enter the name.')

if k in names: 
    print('%s: %d'%(k, names[k]))
else:
    print('There is no ''%s''.'%k)
    names[k] = 1000;

print(names)

Ascending and descending order of dictionary

names = {'Mary':10999, 'Sams':2111, 'Aimy':9778, 'Tom':20245 , 'Michale':27115,
         'Bob':5887, 'Kelly':7855}

def f1(x):
    return x[0]

def f2(x):
    return x[1]

# 1. key, ascending
result1 = sorted(names)
print('result1:', result1)              # ['Aimy', 'Bob', 'Kelly', 'Mary', 'Michale', 'Sams', 'Tom']

result2 = sorted(names.items(), key=f1)
print('result2:', result2)              # [('Aimy', 9778), ('Bob', 5887), ('Kelly', 7855), ('Mary', 10999), ('Michale', 27115), 'Tom']

# 2. key, descending
result3 = sorted(names, reverse=True)
print('result3:', result3)              # ['Tom', 'Sams', 'Michale', 'Mary', 'Kelly', 'Bob', 'Aimy']

result4 = sorted(names.items(), reverse=True , key=f1)
print('result4:', result4)              # [('Tom', 20245), ('Sams', 2111), ('Michale', 27115), ('Mary', 10999), ('Kelly', 7855)y']

# 3. value ascending
result5 = sorted(names.items(), key=f2)
print('result5:', result5)              # [('Sams', 2111), ('Bob', 5887), ('Kelly', 7855), ('Aimy', 9778), ('Mary', 10999),

# 4. value descending
result6 = sorted(names.items(), reverse=True , key=f2)
print('result6:', result6)                # [('Michale', 27115), ('Tom', 20245), ('Mary', 10999), ('Aimy', 9778), ('Kelly', 7855)

 

'Python' 카테고리의 다른 글

Python) list  (0) 2022.11.08
Python) Control statements  (0) 2022.11.06
Python) Tuple / Set  (0) 2022.11.03
Python) Datatypes - Str  (0) 2022.11.03
Python) Variables and Operators  (0) 2022.10.29

Tuple()

Tuple is what only Python has.

It is similar to lists, but there are a few differences.

Your use () instead of [], and once you put the data in the tuple, the data cannot be edited. As lists, you can mix different datatypes in the tuples.

Example1

t1 = ()                         # An empty tuple
t2 = (1,)
t3 = (1,2,3)
t4 = 1, 2, 3
t5 = (30, 3.14, True, False, 'python')
# t5[1] = 42.195               # error: tuple cannot be edited.
t6 = ('a', 'b', 'c', ('ab', 'cd'))

print(type(t1))                 # <class 'tuple'>
print(type(t2))                 # <class 'tuple'>
print(type(t4))                 # <class 'tuple'>
print('t1:', t1)
print('t2:', t2)
print('t3:', t3)
print('t4:', t4)
print('t5:', t5)
print('t6:', t6)

indexing

t1 = (1, 2, 'a', 'b')
print(t1[0])                        # 1
print(t1[1])                        # 2
print(t1[2])                        # a
print(t1[3])                        # b
print(t1[-1])                       # b

slicing

# [ start index : end index ]
t2 = (10, 20, 30, 40, 50)
print(t2[1:3])                      # 1 - 2 : (20, 30)
print(t2[ :4])                      # 0 - 3  : (10, 20, 30, 40)
print(t2[1:])                       # 1 - end : (20, 30, 40, 50)

add

print(t1 + t2)                      # (1, 2, 'a', 'b', 10, 20, 30, 40, 50)
print(t2 + t1)                      # (10, 20, 30, 40, 50, 1, 2, 'a', 'b')

multiply

print(t2 * 3)            # (10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50)

len() with tuple

t1 = (10, 20, 30, 40, 50)
print(len(t1))                      # len : 5
print(t1)                           # (10, 20, 30, 40, 50)

count() with tuple

t2 = (1,100,2,100,3,100,4,100,5,100)
print(t2.count(100))

index() with tuple

t3 = ('java','jsp','python','spring','R','tensorflow','keras')
print(t3.index('spring'))

tuple packing

To bind multiple data into the tuple

t1 = 10, 20, 30
print(type(t1))                     # <class 'tuple'>
print(t1)                           # (10, 20, 30)

tuple unpacking

10 -> one / 20 -> two / 30 -> three

one, two, three = t1
print('one:', one)                  # 10
print('two:', two)                  # 20
print('three:', three)              # 30

 

set()

You can't save overlapped data in set(). It is not an ordered data structure so you can't print the data out in order.

s1 = set([1,2,3,4])
print(type(s1))                     # <class 'set'>
print(s1)                           # {1, 2, 3, 4}

s2 = set('Hello')
print(type(s2))                     # <class 'set'>
print(s2)                           # {'e', 'H', 'o', 'l'}

set() -> list() 

list1 = list(s3)
print(type(list1))                  # <class 'list'>
print(list1)                        # [1, 2, 3]
print(list1[0])                     # 1
print(list1[1])                     # 2
print(list1[2])                     # 3

set() -> tuple()

t1 = tuple(s3)
print(type(t1))                     # <class 'tuple'>
print(t1)                           # (1, 2, 3)
print(t1[0])                        # 1
print(t1[1])                        # 2
print(t1[2])                        # 3

intersection(), union(), and difference()

s1 = set([1,2,3,4,5,6])
s2 = set([4,5,6,7,8,9])

# 1. intersection()
print(s1 & s2)                          # {4, 5, 6}
print(s1.intersection(s2))              # {4, 5, 6}

# 2. union()
print(s1 | s2)                          #  {1, 2, 3, 4, 5, 6, 7, 8, 9}
print(s1.union(s2))                     #  {1, 2, 3, 4, 5, 6, 7, 8, 9}

# 3. difference()
print(s1 - s2)                          # {1, 2, 3}
print(s1.difference(s2))                # {1, 2, 3}

print(s2 - s1)                          # {8, 9, 7}
print(s2.difference(s1))                # {8, 9, 7}

add(), update(), and remove()

# 1. add() 
s1 = set([1, 2, 3])
s1.add(3)                          # Overlapped data cannot be saved.
s1.add(4)
# s1.add([4, 5])                   # Only one data can be saved.
print(s1)                          # {1, 2, 3, 4}

# 2. update() : to add multiple data
s2 = set([1, 2, 3])
s2.update([4, 5, 6])
print(s2)                           # {1, 2, 3, 4, 5, 6}

# 3. remove() 
s3 = set([1, 2, 3])
s3.remove(2)                       
s3.remove(3)                       
print(s3)                           # {1}

'Python' 카테고리의 다른 글

Python) Control statements  (0) 2022.11.06
Python) Dictionary  (0) 2022.11.04
Python) Datatypes - Str  (0) 2022.11.03
Python) Variables and Operators  (0) 2022.10.29
Python) Configuration and Basics  (0) 2022.10.27
Text Type: str
Numeric Types: int, float, complex
Sequence Types: list, tuple, range
Mapping Type: dict
Set Types: set, frozenset
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
None Type: NoneType

String 

s1 = 'Hello World'
print(type(s1))                 # <class 'str'>
print(s1)

s2 = "Python is fun"
print(type(s2))                 # <class 'str'>
print(s2)

s3 = '''Life is too short, you need python.'''
print(type(s3))                 # <class 'str'>
print(s3)

s4 = """Life is too short, you need python."""
print(type(s4))                 # <class 'str'>
print(s4)

Unlike other languages, in Python, you can add and multiply the strings. 

head = 'Python'
tail = ' is fun'
str = head + tail
print(str)                     
print(head + tail)             

s = 'python'
print(s * 2)                  
print(s * 3)                   

print('='*50)                 
print('My Program')
print('='*50)                  

print('*'*1)
print('*'*2)
print('*'*3)
print('*'*4)
print('*'*5)

print('*'*5)
print('*'*4)
print('*'*3)
print('*'*2)
print('*'*1)

Indexing

Indexing is used when you need to extract parts of the data. 

The first letter is index'0', and the last letter is index'-1'. 

s = 'Life is too short, you need python'
print(s)

print(s[0])                 # L
print(s[3])                 # e
print(s[-1])                # n
print(s[-2])                # o

str = 'korea'
print(str[0])               # k
print(str[-2])              # e

Slicing

Example1

# format :  variable[ start : stop ]

s = 'Life is too short, you need python'

print(s[0:2])         # 0 - 1 : Li
print(s[0:5])         # 0 - 4 : Life
print(s[5:7])         # 5 - 6 : is
print(s[12:17])       # 12 - 16 : short

print(s[ : 7])        # 0 -6 : Life is

print(s[5 : ])        # 5 - last : is too short, you need python

print(s[ : ])         # first - last


str = '20201024Rainy'
date = str[:8]              # 20201024
weather = str[8:]           # Rainy
print(date,':', weather)


year = str[:4]              # 2020
month = str[4:6]            # 10
day = str[6:8]              # 24
print(year, 'Year', month, 'Month', day, 'Day')

 

Example2

str = 'korea'

print(str[0])           # [0] : k
print(str[-2])          # The second last : e

print(str[1:3])         # 1 - 2 : or
print(str[0:5:2])       # 0 - 4 (+2) : kra
print(str[:-1])         # first - -2 : kore
print(str[::-1])        # reverse : aerok

Example3 

To change strings with slicing, you need to slice first and combine the letters.

s = 'pithon'
print(s[1])                       # i

# i -> y 
# s[1] = 'y'                      # TypeError: 'str' object does not support item assignment

s = s[:1] + 'y' + s[2:]           # python
print(s)

 

Functions

upper() / lower()

txt = 'A lot of things happen everyday.'

result1 = txt.upper()
result2 = txt.lower()

print('result1:', result1)  #result1: A LOT OF THINGS HAPPEN EVERYDAY.
print('result2:', result2)  #result2: a lot of things happen everyday.

format()

%s String
%c Character
%d Integer
%f float
%%
txt1 = 'Java'; txt2 = 'Python'
num1 = 5; num2 = 10

print('I like %s and %s!' %(txt1, txt2))
print('%s is %d times easier than %s.' %(txt2,num1,txt1))
print('%d + %d = %d' %(num1, num2, num1+num2))
print('Inflation rate in 2022: %d%%' %num1)

len()

msg = input('Insert a sentence.')
print(type(msg))
len = len(msg)                

print('The length of the sentence is ', len,'.')
print('The length of the sentence is {}.'.format(len))
print('The length of the sentence is %d.'%len)

count()

txt = 'A lot of things occur each day, every day.'

count1 = txt.count('o')            
count2 = txt.count('day')         
count3 = txt.count(' ')           

print('count1:', count1)
print('count2:', count2)
print('count3:', count3)

escape()

\n enter
\t tab
\\ print"\"
\' print"'"
\" print"""
print('I love Python.\n Python is easier than other languages!')
print('Name:John Simth\tSex:Male\tAge:22')
print('\"Welcome to Meadow\'s devlog!\"')
print('\'python\"')                
print('\\Java\\')

find()

txt = 'Today is Tuesday! I love Tuesdays.'

offset1 = txt.find('e')         # first 'e'
offset2 = txt.find('day')       # first 'day'
offset3 = txt.find('day', 20)   # 'day' after index[20]
offset4 = txt.find('j')         # no 'j' => returns -1

print('offset1:', offset1)		#11
print('offset2:', offset2)		#2
print('offset3:', offset3)		#29
print('offset4:', offset4)		#-1

 

strip()

txt = '    I am hungry!    '

result1 = txt.lstrip()  
result2 = txt.rstrip()
result3 = txt.strip()

print('<'+txt+'>')   #<    I am hungry!    >
print('<'+result1+'>')  #<I am hungry!    >
print('<'+result2+'>')  #<    I am hungry!>
print('<'+result3+'>') #<I am hungry!>

isdigit()

txt1 = '010-1234-5678'
txt2 = 'R2D2'
txt3 = '1212'

result1 = txt1.isdigit()
result2 = txt2.isdigit()
result3 = txt3.isdigit()

print('result1:', result1)          # False 
print('result2:', result2)          # False
print('result3:', result3)          # True

 

'Python' 카테고리의 다른 글

Python) Control statements  (0) 2022.11.06
Python) Dictionary  (0) 2022.11.04
Python) Tuple / Set  (0) 2022.11.03
Python) Variables and Operators  (0) 2022.10.29
Python) Configuration and Basics  (0) 2022.10.27

In this post, we will talk about variables in Python.

Depending on the language, variables, data types, and syntaxes differ.

# Variables : Name of the memory space for a certain type of data
# Format : variable name = value(data)

#Integer
i = 10
print('i=', i)
print(type(i))      #<class 'int'>

#Float
r = 3.14
print('r=', r)
print(type(r))      #<class 'float'>
# In Java, there are double and float, however, in Python, there is only float variable.

# Complex numbers
c = 3 + 5j
print('c=', c)
print(type(c))

# Boolean
b1 = True
b2 = False
#The first letter has to be upper case.
print('b1=', b1)
print('b2=', b2)
print(type(b1))
print(type(b2))     # <class 'bool'>

#String
s1 = "Meadow"
s2 = "Dodo"
print('s1=', s1)
print('s2=', s2)
print(type(s1))
print(type(s2))

#List
list = ['South Korea', 'China', 'Canada', 'Kenya', 'Germany']
print(list[0])          #Indexing : red
list[1] = 'Mexico'
print('list=', list)
print(type(list))       #<class 'list'>

#Tuple
t =('Argentina', 'America', 'Singapore', 'Australia', 'Laos')
print(t[0])         #Indexing
#t[0] ='Chile'       #The values in Tuple can't be edited.
print('t=', t)
print(type(t))

#Dictionary : { 'key' : 'value'}
#Map in Java
d = {'Google' : 'http://www.google.com',
     'Apple' : 'http://www.apple.com',
     'Naver' : 'http://www.naver.com'}
print('d=', d)
print(type(d))

Python has very different operators from other languages, which make human more convenient to program. 

For this reason, we will pour over these operators. 

 

Assignment Operators

The function of assignment operators is different from other languages in that there are no such functions that you can exchange values without assigning a temporal variable in other languages. 

# Assignment Operators
a = 10
print('a=', a)
x = y = z = 0
print('x=', x)
print('y=', y)
print('z=', z)

c, d = 10, 20
print('c=', c)
print('d=', d)

# Exchanging values
c, d = d, c
print('c=', c)
print('d=', d)

Arithmetic Operators

# Arithmetic Operators
# +,-,* /Division (float), //Division (floor), %(Modulus), **(Exponent)

a = 10; b = 3

result1 = a + b
result2 = a - b
result3 = a * b
result4 = a / b
result5 = a // b
result6 = a % b
result7 = a ** b

Comparison Operators 

In Python, you can compare strings, too. The comparison of strings works with decimal ASCII Code. 

The ASCII for ‘A’ is 65, and for ‘a’, it is 97 so 'a' will be greater than 'A' if you compare them.

If the strings are more than one, it will compare to the first letters. 

# Comparison (Relational) Operators
# Boolean
x = 10; y = 20
str1 = 'abc'
str2 = 'python'

print( x == y)
print( x != y)
print( x > y)
print( x >= y)
print( x < y)
print( x <= y)

print(str1 == str2)
print(str2 == 'python')
print(str1 < str2)

Logical Operators

Unlike Java, in Python, we don't use operator symbols but AND OR NOT.

Logical Operator Description
A and B If both operands are true, then the condition becomes true.
A or B  The condition becomes true if any of the two operands are non-zero.
not A Used to reverse the logical state of its operand.
# Logical Operators
# AND OR NOT
b1 = True; b2 = False; b3=True; b4=False

print(b1 and b2) #False
print(b1 and b3) #True
print(b2 or b3)  #True
print(b2 or b4)  #False
print(not b1)    #False
print(not b2)    #True

 

Now, let us create a program that prints the pass or fail of 5 subjects(minimum 40, avg 60) entered on the keyboard.

When it comes to if ~ else statement in Python, indentation is necessary.

n1 = int(input('Insert score1'))
n2 = int(input('Insert score2'))
n3 = int(input('Insert score3'))
n4 = int(input('Insert score4'))
n5 = int(input('Insert score5'))

avg = (n1+n2+n3+n4+n5) / 5      #float
print('avg=', avg)

if n1 >= 40 and n2 >= 40 and n3 >= 40 and n4 >= 40 and n5 >= 40 and avg >=60:
    print('Pass')
else:
    print('Fail')

 Augmented Assignment Operators

#Augmented Assignment Operators

a = 0    #Initial value

a += 1
print(a)

a -=5 
print(a)

a *= 2
print(a)

a /= 4
print(a)

Membership Operators

These operators are only in Python. It is a beneficial function, like the search function, that you can use when you put Ctrl + F.

Membership Operator Description
in Evaluates to true if it finds a variable in the specified sequence and false otherwise.
not in Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.

Example 1

# Membership Operators : in , not in

list = [10, 20, 30, 40, 50]

result1 = 30 in list
result2 = 60 in list
print('result1=', result1)  #True
print('result2=', result2)  #False

str = 'abcde'
result3 = 'c' in str
resuslt4 = 'k' in str
print('result3=', result3)  #True
print('result4=', result4)  #False

Example 2

# Membership Operators : in , not in
msg = input('How are you?')

if 'a' in msg:
    print('There is ''a'' in your reply.')
else:
    print('There is no ''a'' in your reply.')

Example 3

months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

for i in months:
    if 'r' in i:
         print(i)

'Python' 카테고리의 다른 글

Python) Control statements  (0) 2022.11.06
Python) Dictionary  (0) 2022.11.04
Python) Tuple / Set  (0) 2022.11.03
Python) Datatypes - Str  (0) 2022.11.03
Python) Configuration and Basics  (0) 2022.10.27

프로젝트 진행 계획을 수립했습니다. 

 

프로젝트 진행 계획

1. 프로젝트 주제 선정
  - 목적 및 기대효과

2. 요구사항 분석
  - Client의 요구사항 반영

3. 스토리 보드 작성(화면 UI)
  - 메인 페이지 및 서브 페이지

4. 작업 흐름도(WorkFlow)
  ex) 회원가입 - 로그인 - 정보수정
                                 로그아웃
                                 회원탈퇴
5. DB 설계 및 구축
   - exErd, sql developer etc

 

6. 업무 분담, 스케줄 설정

 

7. UI 설계 및 UI 구현
   - 웹표준, bootstrap, smart editor etc


8. 클래스 설계 및 구축
   UML
  
9. 테스트 및 디버깅

10. 이행
   개발 환경에서 운영 서버로 업로드

11. 프로젝트 발표 및 시연

 

요구사항 분석

요구사항 분석은 계속 업데이트 할 예정이다. 현재까지는 개괄적인 기능과 요구사항, 그리고 더 필요한 사항에 대해 기입했습니다. 요구사항 분석 후에는 각자 역할을 나누어 UI를 설계해 볼 예정입니다. 

개발언어 선정 

현재까지 선정한 개발 언어들은 다음과 같습니다.  

Front HTML, CSS, BootStrap, JavaScript, jQuery
Apache Tomcat, AWS(EC2)
Back Java, JSP, Spring  
Database Oracle, eXERD  
Library 관리자 Maven  

 

Python is Google's three most advanced programming languages. Guido van Rossum, a programmer, made Python, one of the script languages. The name Python is from Guido's favorite comedy program. It's from Monty Python's Flying Circus.

 

To compare Python to C, Python codes are way shorter and more straightforward. In Python, code blocks are fundamental since the loops work with the indentations.

 

To download Python, you can download it directly from the official website.

Download Python | Python.org

You can also download Anaconda, which includes Python, Jupyter notebook, pandas, scipy, and other libraries. 

Anaconda | Anaconda Distribution

 

After downloading it, check on the command prompt by inserting Python to check if it is downloaded well. If you see this >>>, it means it is there.

You will see the libraries in Anaconda if you insert the pip list.

Check if jupyter notebook is also set up; if so, let's open jupyter. 

You will see these new pop-ups.

Click New- Python 3(ipykernel) to create a new notebook.

In this notebook, you can run the codes directly and efficiently like the one below. 

You can click the run button to run the codes or use the hotkey Ctrl + Enter or Shift + Enter.

 

Now, we will download PyCharm

If you want to download the other versions, click here: https://www.jetbrains.com/ko-kr/pycharm/download/other.html.

After downloading, to create a project, click New Project.

This pythonProject will be the name of the project that you will make. 

Run main.py to see if there is a virtual environment.  

For the basic configurations, you can set them up in the Settings menu.

To install the keymap plugins that PyCharm doesn't have, click Get more keymaps in Settings / Plugins.

I will download the Eclipse keymap.

Here in Python Interpreter, you can see the libraries list. You can easily install, uninstall, or upgrade them. 

Now, let us create a file and run it.

Here are some eclipse hotkeys that I use a lot. 

#Eclipse Keymap
# To execute : Ctrl + F11
# To Copy and Paste : Ctrl + Alt + Pg Dn
# To comment out : Ctrl + /

 

Python is a functional language, so there are many built-in Functions. The link below is about the built-in functions in Python.

Built-in Functions — Python 3.7.14 documentation

 

The syntax differs from Java, so you may need to learn the difference. 

For example, in Java, you must put a semicolon on every line when the line finishes. In Python, you do not need semicolons except for writing more than two codes in one line. 

print('Java'); print('Python')

To see the reserved list, follow this: 

import keyword
print(keyword.kwlist)

Commenting is also different. Here, we use #, ''', and """

 

In the next post, we will discuss more syntaxes and basic rules in Python.

 

 

'Python' 카테고리의 다른 글

Python) Control statements  (0) 2022.11.06
Python) Dictionary  (0) 2022.11.04
Python) Tuple / Set  (0) 2022.11.03
Python) Datatypes - Str  (0) 2022.11.03
Python) Variables and Operators  (0) 2022.10.29

그룹 프로젝트 기간: 10/24 ~ 11/18

 

프로젝트 기간은 한 달입니다. 아직 어떤 프로젝트를 해야 한 달안에 구현할 수 있는지 잘 모르는 상태라 기존 서비스를 모델로 한 다양한 주제들이 나왔습니다. 

쇼핑몰 (당근마켓) 

익명 커뮤니티 (바비톡)

제품리뷰 사이트(네이버리뷰)

여행 커뮤니티(유랑)

비행기 예약(스카이스캐너)

리뷰사이트(다나와) 

데이팅사이트

영화예매사이트

캠핑용품 쇼핑몰

소모임 샤이트(소모임, Meet up)

부동산 사이트(직방, 다방)

펜션예약사이트

 

각 주제별로 어떤 기능을 구현해야 하는지, 우리에게 주어진 시간동안 구현할 수 있는 지 이야기를 해본 후, 최종적으로 소모임 사이트에 대해서 더 이야기 해보기로 했습니다.

 

마인드맵으로 어떤 기능이 필요한지, 넣고 싶은 기능이 있다면 어떻게 구현할 건지 이야기 해보았습니다. 

아직 기능 구현에 대한 구체적인 이야기보다 개괄적인 내용에 대한 토의를 했습니다. 

+ Recent posts