목록IT (97)
개발로그필름
# 자료구조의 변경 # 커피숍 menu = {"커피", "우유", "주스"} print(menu, type(menu)) # {} menu = list(menu) print(menu, type(menu)) # [] menu = tuple(menu) print(menu, type(menu)) # () menu = set(menu) print(menu, type(menu)) # {}
WebMarket/src/dao/ProductRepository.java package dao; import java.util.ArrayList; import dto.Product; public class ProductRepository { private ArrayList listOfProducts = new ArrayList(); public ProductRepository() { Product phone = new Product("P1234", "iPhone 6s", 800000); phone.setDescription("4.7-inch, 1334X750 Renina HD display, 8-megapixel iSight Camera"); phone.setCategory("Smart Phone"); ..
Quiz 당신의 학교에서는 파이썬 코딩 대회를 주최합니다. 참석률을 높이기 위해 댓글 이벤트를 진행하기로 하였습니다. 댓글 작성자들 중에 추첨을 통해 1명은 치킨, 3명은 커피 쿠폰을 받게 됩니다. 추첨 프로그램을 작성하시오 조건 조건 1 : 편의상 댓글은 20명이 작성하였고 아이디는 1~20이라고 가정 조건 2 : 댓글 내용과 상관 없이 무작위로 추첨하되 중복 불가 조건 3 : random 모듈의 shuffle과 sample을 활용 코드 from random import * users = range(1, 21) # 1부터 20까지 숫자를 생성 users = list(users) # range타입을 list타입으로 변경 shuffle(users) # 섞기 winners = sample(users, 4) ..
weather = input("오늘 날씨는 어때요? ") if weather == "비" or weather == "눈": print("우산을 챙기세요") elif weather == "미세먼지": print("마스크를 챙기세요") else: print("준비물 필요 없어요") temp = int(input("기온은 어때요? ")) if 30
WebMarket/src/dto/Product.java package dto; import java.io.Serializable; public class Product implements Serializable { // private static final long serialVersionUID = -427474700572038677000L;; private String productId; // 상품 아이디 private String pname; // 상품명 private Integer unitPrice; // 상품 가격 private String description; // 상품 설명 private String manufacturer; // 제조사 private String category; // 분류..
for waiting_no in [0, 1, 2, 3, 4]: print("대기번호 : {0}".format(waiting_no)) for waiting_no in range(5): # 0, 1, 2, 3, 4 print("대기번호 : {0}".format(waiting_no)) for waiting_no in range(1, 6): # 1, 2, 3, 4, 5 print("대기번호 : {0}".format(waiting_no)) starbucks = ["아이언맨", "토르", "아이엠 그루트"] for customer in starbucks: print("{0}, 커피가 준비되었습니다.".format(customer))
# while customer = "토르" index = 5 while index >= 1: print("{0}, 커피가 준비 되었습니다. {1}번 남았어요.".format(customer, index)) index -= 1 if index == 0: print("커피는 폐기처분 되었습니다.") # 무한루프 customer = "아이언맨" index = 10 while True: print("{0}, 커피가 준비되었습니다. 호출 {1}회".format(customer, index)) index += 1 customer = "토르" person = "Unknown" while person != customer : print("{0}, 커피가 준비 되었습니다.".format(customer)) person ..
def open_accout(): print("새로운 계좌가 생성되었습니다.") def deposit(balance, money): # 입금 print("입금이 완료되었습니다. 잔액은 {0}원 입니다.".format(balance + money)) return balance + money def withdraw(balance, money): # 출금 if balance >= money: # 잔액이 출금보다 많으면 print("출금이 완료되었습니다. 잔액은 {0}원 입니다.".format(balance - money)) return balance - money else: print("출금이 완료되지 않았습니다. 잔액은 {0}원 입니다.".format(balance)) return balance def wi..