# 6065 : 짝수만 순서대로 줄을 바꿔 출력

n1, n2, n3 = input().split()
n1 = int(n1)
n2 = int(n2)
n3 = int(n3)
if n1 % 2 == 0:
    print(n1)
if n2 % 2 == 0:
    print(n2)
if n3 % 2 == 0:
    print(n3)

 

# 6066 : 입력된 순서대로 짝(even)/홀(odd)을 줄을 바꿔 출력

n1, n2, n3 = input().split()
n1 = int(n1)
n2 = int(n2)
n3 = int(n3)
if n1 % 2 == 0:
    print("even")
else:
    print("odd")
if n2 % 2 == 0:
    print("even")
else:
    print("odd")
if n3 % 2 == 0:
    print("even")
else:
    print("odd")

 

# 6067 : 음수, 짝수이면 A | 음수, 홀수이면 B | 양수, 짝수이면 C | 양수, 홀수이면 D를 출력

n = int(input())
if n < 0:
    if n % 2 == 0:
        print("A")
    else:
        print("B")
else:
    if n % 2 == 0:
        print("C")
    else:
        print("D")

 

# 6068 : 평가 결과를 출력

score = int(input())
if score <= 100 and score >= 90:
    print("A")
elif score <= 89 and score >= 70:
    print("B")
elif score <= 69 and score >= 40:
    print("C")
elif score <= 39 and score >= 0:
    print("D")

↓ 다른 정답 코드

score = int(input())
if score >= 90:
    print("A")
elif score >= 70:
    print("B")
elif score >= 40:
    print("C")
else:
    print("D")

 

# 6069 : 문자에 따라 다른 내용이 출력

ch = input()
if ch=='A':
    print("best!!!")
elif ch=='B':
    print("good!!")
elif ch=='C':
    print("run!")
elif ch=='D':
    print("slowly~")
else:
    print("what?")

 

# 6070 : 계절 이름을 출력

month = int(input())
if month == 12 or month == 1 or month == 2:
    print("winter")
elif month == 3 or month == 4 or month == 5:
    print("spring")
elif month == 6 or month == 7 or month == 8:
    print("summer")
elif month == 9 or month == 10 or month == 11:
    print("fall")

// else는 생략 가능

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6077-6087 (Python)  (0) 2022.11.13
[CodeUp] 6071-6076 (Python)  (0) 2022.11.12
[CodeUp] 6063-6064 (Python)  (0) 2022.11.10
[CodeUp] 6059-6062 (Python)  (0) 2022.11.09
[CodeUp] 6052-6058 (Python)  (0) 2022.11.08

# 6063 : 두 정수 중 큰 값을 10진수로 출력(단, 3항 연산 사용)

n1, n2 = input().split()
n1 = int(n1)
n2 = int(n2)
print(n1 if(n1>=n2) else n2)

// 3항 연산은 "x if C else y"의 형태로 작성,

(C는 조건식 또는 값, xC가 True일 때 값, yC가 False일 때 값)

 

# 6064: 가장 작은 값을 출력

n1, n2, n3 = input().split()
n1 = int(n1)
n2 = int(n2)
n3 = int(n3)
print((n1 if (n1<=n2) else n2) if (n2<=n3) else n3)

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6071-6076 (Python)  (0) 2022.11.12
[CodeUp] 6065-6070 (Python)  (0) 2022.11.11
[CodeUp] 6059-6062 (Python)  (0) 2022.11.09
[CodeUp] 6052-6058 (Python)  (0) 2022.11.08
[CodeUp] 6048-6051 (Python)  (0) 2022.11.07

# 6059 : 비트 단위로 1→0, 0→1로 바꾼 후 그 값을 10진수로 출력

n = int(input())
print(~n)

 

# 6060 : 두 정수를 비트단위로 and 계산을 수행한 결과를 10진수로 출력 (틀린코드)

n1, n2 = input().split()
print(int(n1) and int(n2))
--> 입력: 3 5
--> 코드 출력: 5
--> 정답 출력: 1

// 비트 단위 연산자는 &를 사용한다.

 

# 6060 : 두 정수를 비트단위로 and 계산을 수행한 결과를 10진수로 출력

n1, n2 = input().split()
print(int(n1) & int(n2))

 

# 6061 : 두 정수를 비트단위로 or 계산을 수행한 결과를 10진수로 출력

n1, n2 = input().split()
print(int(n1) | int(n2))

 

# 6062 : 두 정수를 비트단위로 xor 계산을 수행한 결과를 10진수로 출력

n1, n2 = input().split()
print(int(n1) ^ int(n2))

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6065-6070 (Python)  (0) 2022.11.11
[CodeUp] 6063-6064 (Python)  (0) 2022.11.10
[CodeUp] 6052-6058 (Python)  (0) 2022.11.08
[CodeUp] 6048-6051 (Python)  (0) 2022.11.07
[CodeUp] 6046-6047 (Python)  (0) 2022.11.06

# 6052 : 입력된 값이 0이면 False, 0이 아니면 True를 출력

n = int(input())
print(bool(n))

// bool() 을 이용하면 입력된 식이나 값을 평가해 불 형의 값(True 또는 False)을 출력한다.

 

# 6053 : 입력된 정수의 불 값이 False 이면 True, True이면 False를 출력

n = int(input())
if bool(n) == False:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

n = bool(int(input()))
print(not n)

// True 또는 False의 논리값을 역으로 바꾸기 위해서 not 예약어를 사용할 수 있다.

 

# 6054 : 둘 다 True일 경우에만 True를  출력하고, 그 외의 경우에는 False를 출력

n1, n2 = input().split()
n1 = bool(int(n1))
n2 = bool(int(n2))
if n1==n2==True:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

n1, n2 = input().split()
print(bool(int(n1)) and bool(int(n2)))

 

# 6055 : 하나라도 참일 경우 True를 출력하고, 그 외의 경우에는 False를 출력

n1, n2 = input().split()
print(bool(int(n1)) or bool(int(n2)))

 

# 6056 : 두 값의 True / False 값이 서로 다를 경우만 True를 출력하고, 그 외에 경우에는 False 출력

n1, n2 = input().split()
print(bool(int(n1)) ^ bool(int(n2)))

↓ 다른 정답 코드

n1, n2 = input().split()
n1 = bool(int(n1))
n2 = bool(int(n2))
print((n1 and (not n2)) or ((not n1) and n2))

 

# 6057 : 두 값의 True / False 값이 서로 같을 경우만 True를 출력하고, 그 외에 경우에는 False 출력

n1, n2 = input().split()
if bool(int(n1)) == bool(int(n2)):
    print(True)
else:
    print(False)

↓ 다른 정답 코드

n1, n2 = input().split()
n1 = bool(int(n1))
n2 = bool(int(n2))
print(n1==n2)

 

# 6058 : 두 값의 True / False 값이 모두 False일 때만 True를 출력하고, 그 외에 경우에는 False 출력

n1, n2 = input().split()
if bool(int(n1)) == bool(int(n2)) == False:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

n1, n2 = input().split()
n1 = bool(int(n1))
n2 = bool(int(n2))
print(not (n1 or n2))
n1, n2 = input().split()
n1 = bool(int(n1))
n2 = bool(int(n2))
print(n1==False and n2==False)

 

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6063-6064 (Python)  (0) 2022.11.10
[CodeUp] 6059-6062 (Python)  (0) 2022.11.09
[CodeUp] 6048-6051 (Python)  (0) 2022.11.07
[CodeUp] 6046-6047 (Python)  (0) 2022.11.06
[CodeUp] 6032-6045 (Python)  (0) 2022.11.05

# 6048 :a가 b보다 작으면 True를, a가 b보다 크거나 같으면 False 출력

a, b = input().split()
a = int(a)
b = int(b)
if a<b:
    result = True
else:
    result = False
print(result)

↓ 다른 정답 코드

a, b = input().split()
a = int(a)
b = int(b)
print(a<b)

 

# 6049 : a와 b의 값이 같으면 True를, 같지 않으면 False를 출력

a, b = input().split()
a = int(a)
b = int(b)
if a==b:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

a, b = input().split()
a = int(a)
b = int(b)
print(a==b)

 

# 6050 : b의 값이 a의 값 보다 크거나 같으면 True를, 같지 않으면 False를 출력

a, b = input().split()
a = int(a)
b = int(b)
if b>=a:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

a, b = input().split()
a = int(a)
b = int(b)
print(a<=b)

 

# 6051 : a와 b가 다를 경우 True를, 그렇지 않은 경우 False를 출력

a, b = input().split()
a = int(a)
b = int(b)
if a!=b:
    print(True)
else:
    print(False)

↓ 다른 정답 코드

a, b = input().split()
a = int(a)
b = int(b)
print(a!=b)

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6059-6062 (Python)  (0) 2022.11.09
[CodeUp] 6052-6058 (Python)  (0) 2022.11.08
[CodeUp] 6046-6047 (Python)  (0) 2022.11.06
[CodeUp] 6032-6045 (Python)  (0) 2022.11.05
[CodeUp] 6027-6031 (Python)  (0) 2022.11.04

# 6046 : 정수 1개 입력 받아 2배 곱해 출력

n = int(input())
print(n<<1)

 

# 6047 : 2의 거듭제곱 배로 곱해 출력

a, b = input().split()
print(int(a)<<int(b))

# a를 2^b배 곱한 값으로 출력하려면 print(a<<b)를 해야 한다.

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

 

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6052-6058 (Python)  (0) 2022.11.08
[CodeUp] 6048-6051 (Python)  (0) 2022.11.07
[CodeUp] 6032-6045 (Python)  (0) 2022.11.05
[CodeUp] 6027-6031 (Python)  (0) 2022.11.04
[CodeUp] 6025-6026 (Python)  (0) 2022.11.03

# 1088 : 수 나열하기(등차)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        int result = a + (d*(n-1));
        System.out.println(result);
        sc.close();
    }
}

 

# 1090 : 수 나열하기(등비)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int r = sc.nextInt();
        int n = sc.nextInt();
        long result = a * (long)(Math.pow(r, n-1));
        System.out.println(result);
        sc.close();
    }
}

// long 타입으로 해야 됨

 

# 1091 : 수 나열하기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int m = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        long num = a;
        for(int i=1; i<n; i++) {
            num = num * m + d;
        }
        System.out.println(num);
        sc.close();
    }
}

// long 타입으로 해야 됨

 

# 1092 : 함께 문제 푸는 날(최소 공배수)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int day = 1;
        while(day%a!=0 || day%b!=0 || day%c!=0) {
            day++;
        }
        System.out.println(day);
        sc.close();
    }
}

 

# 1093 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[23];
        for(int i=0; i<n; i++) {
            arr[sc.nextInt()-1]++;
        }
        for(int i=0; i<arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
        sc.close();
    }
}

 

# 1094 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        for(int i=n-1; i>=0; i--) {
            System.out.print(arr[i]+" ");
        }
        sc.close();
    }
}

 

# 1095 : 이상한 출석 번호 부르기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
        }
        int min = arr[0];
        for(int i=0; i<n; i++) {
            if (min>arr[i]) {
                min = arr[i];
            }
        }
        System.out.println(min);
        sc.close();
    }
}

 

# 1096 : 바둑판에 흰 돌 놓기

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[][] = new int[20][20];
        for(int i=1; i<=n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            arr[x][y] = 1;
        }
        for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                System.out.printf("%d ", arr[i][j]);
            }
            System.out.println("");
        }
        sc.close();
    }
}

 

# 1097 : 바둑알 십자 뒤집기(이건 좀)

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int arr[][] = new int[20][20];
         for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        int n = sc.nextInt();
        for(int k=1; k<=n; k++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            for(int i=1; i<=19; i++) {
                if(arr[x][i]==0) {
                    arr[x][i] = 1;
                }
                else {
                    arr[x][i] = 0;
                }
            }
            for(int j=1; j<=19; j++) {
                if(arr[j][y]==0) {
                    arr[j][y] = 1;
                }
                else {
                    arr[j][y] = 0;
                }
            }
        }
        for(int i=1; i<=19; i++) {
            for(int j=1; j<=19; j++) {
                System.out.print(arr[i][j]+" ");
            }
            System.out.println("");
        }
        sc.close();
    }
}

 

# 1098 : 설탕 과자 뽑기 

 

#1099 : 성실한 개미 

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Java' 카테고리의 다른 글

[CodeUp] 1078-1088 (Java)  (0) 2022.11.05
[CodeUp] 1071-1077 (Java)  (0) 2022.11.04
[CodeUp] 1065-1070 (Java)  (0) 2022.11.03
[CodeUp] 1063-1064 (Java)  (0) 2022.11.02
[CodeUp] 1059-1062 (Java)  (0) 2022.11.01

# 6032 : 정수 1개 입력 받아 부호 바꾸기

n = int(input())
print(-n)

 

# 6033 : 문자 1개 입력 받아 다음 문자 출력

c = input()
c = ord(c)+1 # c의 유니코드 정수를 반환후 1를 더함
print(chr(c)) # c의 유니코드 문자 반환

 

# 6034 : 정수 2개 입력 받아 차 계산 (틀린코드)

n1, n2 = int(input()).split()
print(n1 - n2)
--> ValueError: invalid literal for int() with base 10: '123 -123'
--> 파이썬 형변환 에러

 

# 6034 : 정수 2개 입력 받아 차 계산

n1, n2 = input().split()
n1 = int(n1)
n2 = int(n2)
print(n1-n2)

// input().split() : 공백을 기준으로 입력된 값들을 나누어 자른다.

 

# 6035 : 실수 2개 입력 받아 차 계산

f1, f2 = input().split()
m = float(f1) * float(f2)
print(m)

 

# 6036 : 단어 여러 번 출력

w, n = input().split()
print(w * int(n))

// 문자열 * N : 문자열 N만큼 반복

 

# 6037 : 문장 여러 번 출력

n = int(input())
s = input()
print(s*n)

 

# 6038 : 정수 2개 입력 받아 거듭제곱 계산

n1, n2 = input().split()
e = int(n1) ** int(n2)
print(e)

 

# 6039 : 실수 2개 입력 받아 거듭제곱 계산

f1, f2 = input().split()
e = float(f1) ** float(f2)
print(e)

 

# 6040 : 정수 2개 입력 받아 나눈 몫 계산 (틀린코드)

n1, n2 = input().split()
n = int(n1) / int(n2)
print(n)
--> 입력: 10 3
--> 출력: 3.3333333333333335

 

# 6040 : 정수 2개 입력 받아 나눈 몫 계산 

n1, n2 = input().split()
n = int(n1) // int(n2)
print(n)

// 나눗셈의 몫을 구하려면 슬래시 2번 (//) 을 써야 한다.

 

# 6041 : 정수 2개 입력 받아 나눈 나머지 계산

n1, n2 = input().split()
n = int(n1) % int(n2)
print(n)

 

# 6042 : 실수 1개 입력 받아 소수점이하(2번째) 자리 변환 

f = float(input())
print("%.2f" % f)

 

f = float(input())
print(format(f, ".2f"))
f = float(input())
print(round(f, 2))
f = float(input())
print(f"{f:.2f}")
f = float(input())
print("{:.2f}".format(f))

 

# 6043 : 실수 2개 입력 받아 나눈 결과 계산

f1, f2 = input().split()
f = float(f1) / float(f2)
print("%.3f" % f)
f1, f2 = input().split()
f = float(f1) / float(f2)
print(format(f, ".3f"))
f1, f2 = input().split()
f = float(f1) / float(f2)
print(round(f, 3))
--> 이건 왜 안 돼?!
f1, f2 = input().split()
f = float(f1) / float(f2)
print(f"{f:.3f}")
f1, f2 = input().split()
f = float(f1) / float(f2)
print("{:.3f}".format(f))

 

# 6044 : 정수 2개 입력 받아 자동 계산

n1, n2 = input().split()
print(int(n1) + int(n2)) # 합
print(int(n1) - int(n2)) # 차
print(int(n1) * int(n2)) # 곱
print(int(n1) // int(n2)) # 몫
print(int(n1) % int(n2)) # 나머지
print(format(int(n1) / int(n2), ".2f")) # 소수점 둘째자리까지

 

# 6045 : 정수 3개 입력 받아 합과 평균 출력

n1, n2, n3 = input().split()
hap = int(n1) + int(n2) + int(n3)
print(hap, format((hap/3), ".2f"))

 

https://codeup.kr/index.php

 

CodeUp

☆ 파이썬 다운로드 : 파이썬3 ☆ 무료 C언어 IDE : Code::blocks       DEV C++ ☆ 추천 온라인 IDE : C   C++11   Python3   Java ☆ 채점 가능 언어 : C, C++, JAVA, Python 3.5 ★ C++로 제출시 void main()을 사용하면

codeup.kr

'CodeUp > Python' 카테고리의 다른 글

[CodeUp] 6048-6051 (Python)  (0) 2022.11.07
[CodeUp] 6046-6047 (Python)  (0) 2022.11.06
[CodeUp] 6027-6031 (Python)  (0) 2022.11.04
[CodeUp] 6025-6026 (Python)  (0) 2022.11.03
[CodeUp] 6009-6024 (Python)  (0) 2022.11.02

+ Recent posts