Python Exercise for Beginners # 2 [for Statement / While Statement]

This is a continuation of Python Exercise # 1 for Beginners [Basic Data Types / If Statements]. If you don't understand the problem, you can find an article by google with the keywords listed in "Necessary Knowledge".

Let's go!

Target

  1. You will be able to perform four arithmetic operations
  2. Get used to working with different data types
  3. You will be able to make simple conditional branches with if statements.

About level

★ I use it very often. Let's be able to do it.

★★ It is used when performing a little complicated processing.

★★★ You are studying well. I think I can graduate from Python beginners.

★★★★ It's tricky, but it's often used in Python. Let's remember.

★★★★★ Oh. It seems that Python can be used for business as well! As expected.


Question contents

Python tutorial 4.2 for statement 4.3 range () function 4.4 The else clause of the loop in break and continue statements 4.5. pass statement

--for statement --while statement --How to control the loop


Question 1

(*) For the following problems, create a file as appropriate and execute it from the command line.

Level ★ Required knowledge Display elements of for statement / list using for

Display the data stored in member using the for statement.

sample.py


member = ['tanaka', 'tadokoro', 'tajima', 'tahata', 'takahashi', 'takeda']

Problem 2

Level ★★ Required knowledge enumerate

For each output in Problem 1

'The 〇th is Mr. 〇〇.'

Please display.

Problem 3

Level ★ Required knowledge range

Print a number from 1 to 100

Output example)
1
2
3
...
99
100

Problem 4

Level ★★ Required knowledge range

Output a number from 1 to 100.
However, when it is a multiple of 3,'Fizz'When it is a multiple of 5'Bazz'。
When it is a multiple of 3 and a multiple of 5'FizzBazz'Please display.

Problem 5

Level ★★★ Required Knowledge range / type conversion / string slices / whether a particular value exists in an array

Please output the numbers from 2020 to 3000.
However, when 3 is attached'3 !?'Please be surprised.

// todo: kokokara

Problem 6

Level ★★★

Data is being aggregated. Let's remove strange data and aggregate

Problem 7

Level ★

Display from -30 to 300 using a while statement However, the number with 3 is not output.

Problem 8

Level ★★

Keep going down until Daikichi comes out with a fortune

Problem 9

Level ★★★

Loses when battle HP is low Which one

Problem 10

Level ★★★★

Random rock-paper-scissors

Recommended Posts

Python Exercise for Beginners # 2 [for Statement / While Statement]
Python basics ② for statement
python textbook for beginners
OpenCV for Python beginners
[Python] for statement error
Python list, for statement, dictionary
Learning flow for Python beginners
[For beginners] kaggle exercise (merucari)
Python3 environment construction (for beginners)
Python #function 2 for super beginners
Basic Python grammar for beginners
100 Pandas knocks for Python beginners
Python for super beginners Python #functions 1
[Python / PyQ] 4. list, for statement
Python #list for super beginners
~ Tips for beginners to Python ③ ~
Introduction to Python For, While
[Python] Iterative processing (for, while)
Python Exercise for Beginners # 1 [Basic Data Types / If Statements]
A Java programmer studied Python. (for, if, while statement)
Python for super beginners Python # dictionary type 1 for super beginners
Python #index for super beginners, slices
Python for statement ~ What is iterable ~
<For beginners> python library <For machine learning>
Python #len function for super beginners
Beginners use Python for web scraping (1)
Run unittests in Python (for beginners)
[Python] Multiplication table using for statement
Beginners use Python for web scraping (4) ―― 1
Python #Hello World for super beginners
Python for super beginners Python # dictionary type 2 for super beginners
while statement
[Python] Minutes of study meeting for beginners (7/15)
Let's put together Python for super beginners
[Python] Read images with OpenCV (for beginners)
WebApi creation with Python (CRUD creation) For beginners
Atcoder standard input set for beginners (python)
[For beginners] Try web scraping with Python
A textbook for beginners made by Python beginners
2016-10-30 else for Python3> for:
python [for myself]
Roadmap for beginners
[Super basic] Compare Python, Java and JavaScript (variable, if statement, while statement, for statement)
[Python of Hikari-] Chapter 05-09 Control syntax (use of for statement and while statement properly)
For Else statement
Python exec statement
[Python] if statement
Python assert statement
Beginners practice Python
Python beginner's note
Memo # 4 for Python beginners to read "Detailed Python Grammar"
The fastest way for beginners to master Python
Python for super beginners Python for super beginners # Easy to get angry
Causal reasoning and causal search with Python (for beginners)
For new students (Recommended efforts for Python beginners Part 1)
Memo # 3 for Python beginners to read "Detailed Python Grammar"
Python with Progate (dictionary, while statement, break, continue)
Memo # 1 for Python beginners to read "Detailed Python Grammar"
~ Tips for Python beginners from Pythonista with love ① ~
[Introduction to Udemy Python3 + Application] 40.while else statement
Try to calculate RPN in Python (for beginners)