Three Python questions

Asked 1 years ago, Updated 1 years ago, 485 views

I'm solving Python questions, but these three questions are hard

1) Let's write a program that reads integers and obtains sums and averages. However, the input of integers shall be made within the range where the sum does not exceed 1,000.

Execution Example

Add an integer.
How many more?:4 
Integer: 213
Integer: 314
Integer: 613
The total has exceeded 1,000.
Ignore the last value.
The total is 527
The average is 263.5.

2) Let's write a program that determines whether it is a prime number by reading a positive integer. A prime number is an integer n that is not divided by any number underwater with 2 or more and less than n (i.e., a number divided only by oneself and 1).

Execution Example

An integer greater than or equal to 2:3
It's a minority
An integer greater than or equal to 2:14
It's not a minority

3) Let's write a program to find the product from 1 to n by reading the positive integer n.

Execution Example

positive integer:5
The product from 1 to 5 is 120.

python

2023-05-29 15:53

1 Answers

For question 1, copy the method 1 introduced at https://blockdmask.tistory.com/559 .

For the part "over 1000" in question 1, read and apply the section "Other Control Statement Break" in https://www.nise.go.kr/sedu/pt/page3_05.html .

For question 2, copy the code 1 introduced at https://freedeveloper.tistory.com/391 .

For question 3, copy the final answer from https://dojang.io/mod/page/view.php?id=2353 .

Should I say it? Just ask Chat GPT to make it. Why do you have to solve these questions in the first place? There will be more areas in the world where you can feel more valuable and interested in yourself.


2023-05-29 21:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.