100일간의 코드: 2022년을 위한 완벽한 Python Pro 부트캠프 - 5일차(FizzBuzz)
#🚨 Don't change the code below 👇
student_heights = input("Input a list of student heights ").split()
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
#🚨 Don't change the code above 👆
#Write your code below this row 👇
total_height = 0
for height in student_heights:
total_height += height
print(f"Total height = {total_height}")
number_of_students = 0
for student in student_heights:
number_of_students += 1
print(f"Total students = {number_of_students}")
average_height = round(total_height / number_of_students)
연습 5.2 - 높은 점수
#The aim of the exercise is to use a For Loop function not a max() or min()
#🚨 Don't change the code below 👇
student_scores = input("Input a list of student scores ").split()
for n in range(0, len(student_scores)):
student_scores[n] = int(student_scores[n])
print(student_scores)
🚨 Don't change the code above 👆
#Write your code below this row 👇
top_score = 0
for score in student_scores:
if score > top_score:
top_score = score
#print(top_score)
print(f"The highest score in the class is: {top_score}")
print(average_height)
연습 5.3 - 1 - 100 사이의 짝수 더하기
#Write your code below this row 👇
total = 0
for number in range(1, 101):
if(number %2 == 0):
total += number
print(total)
연습 5.4 - FizzBuzz lol
#Write your code below this row 👇
for fizzbuzz in range(1, 101):
if fizzbuzz % 3 == 0 and fizzbuzz % 5 == 0:
print("Fizzbuzz")
continue
elif fizzbuzz % 3 == 0:
print("Fizz")
continue
elif fizzbuzz % 5 == 0:
print("Buzz")
continue
print(fizzbuzz)
프로젝트 - 비밀번호 생성기
import random
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
symbols = ['!', '#', '$', '%', '&', '(', ')', '*', '+']
print("Welcome to the PyPassword Generator!")
nr_letters= int(input("How many letters would you like in your password?\n"))
nr_symbols = int(input(f"How many symbols would you like?\n"))
nr_numbers = int(input(f"How many numbers would you like?\n"))
#Easy Level - Order not randomized:
#e.g. 4 letter, 2 symbol, 2 number = JduE&!91**
password = ""
for char in range(1, nr_letters + 1):
password += random.choice(letters)
for char in range(1, nr_symbols + 1):
password += random.choice(symbols)
for char in range(1, nr_numbers + 1):
password += random.choice(numbers)
print(password)
#Hard Level - Order of characters randomized:
#e.g. 4 letter, 2 symbol, 2 number = g^2jk8&P**
password_list = []
for char in range(1, nr_letters + 1):
password_list.append(random.choice(letters))
for char in range(1, nr_symbols + 1):
password_list += random.choice(symbols)
for char in range(1, nr_numbers + 1):
password_list += random.choice(numbers)
random.shuffle(password_list)
password = ""
for char in password_list:
password += char
print(f"Your new password is: {password} ")
Reference
이 문제에 관하여(100일간의 코드: 2022년을 위한 완벽한 Python Pro 부트캠프 - 5일차(FizzBuzz)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/mike_kameta_aed62d48c2d0f/100-days-of-code-the-complete-python-pro-bootcamp-for-2022-day-5-21eo텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)