A liberal arts engineer tried knocking 100 language processes in Python 01

For the time being, I'm going to put out the answer of 01 this time.

Python is something fresh and fun because it's usually Java.

01 Take out the 1st, 3rd, 5th, and 7th characters of the character string "Patatokukashi" and get the concatenated character string.

This is the problem this time. Thank you for taking care of the slices this time as well.

01.py


str = u"Patatoku Kashii"
print (str[::2])

I'm writing code like this. It's short for the time being, and I think this is fine, but I feel like I can devise it.

Edited because you pointed out

In python, there is a function called str, and if you use str (123), there is a function that converts it to '123'. In other words, when using this writing method in an environment closer to the actual production, it will be in a situation where you can not use str () even though you want to use it.

So

01.py


s = u"Patatoku Kashii"
print (s[::2])

You should do it like this. The naming of variables and classes is quite appropriate, and Java's habit cannot be removed, so it will be cured. .. .. ..

reference

100 knocks for language processing: 100 knocks for language processing 100 language processing knocks in Python: Qiita

Recommended Posts

A liberal arts engineer tried knocking 100 language processes in Python 02
A liberal arts engineer tried knocking 100 language processes in Python 01
A liberal arts engineer tried knocking 100 language processes in Python 00
I tried a functional language with Python
I tried playing a typing game in Python
I tried adding a Python3 module in C
A story about a liberal arts programming amateur getting a Python 3 engineer certification basic exam
Try to make a Python module in C language
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 1-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 2-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 0-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 5-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 4-
[Beginner] [Python / Django] A fledgling web engineer tried a Django tutorial-Part 3-
Take a screenshot in Python
Create a function in Python
Create a dictionary in Python
I tried to implement a one-dimensional cellular automaton in Python
I tried "a program that removes duplicate statements in Python"
I tried "How to get a method decorated in Python"
Make a bookmarklet in Python
I tried to make a stopwatch using tkinter in python
Draw a heart in Python
Maybe in a python (original title: Maybe in Python)
Write a binary search in Python
[python] Manage functions in a list
Hit a command in Python (Windows)
Draw a scatterplot matrix in python
I tried knocking 100 image processes (Q1 ~ Q10)
ABC166 in Python A ~ C problem
Write A * (A-star) algorithm in Python
Create a binary file in Python
Solve ABC036 A ~ C in Python
Start SQLite in a programming language
Write a vim plugin in Python
Write a depth-first search in Python
I learned about processes in Python
Implementing a simple algorithm in Python 2
Solve ABC037 A ~ C in Python
Run a simple algorithm in Python
Draw a CNN diagram in Python
Create a random string in Python
I tried Line notification in Python
Schedule a Zoom meeting in Python
When writing a program in Python
Python beginner tried 100 language processing knock 2015 (00 ~ 04)
You will be an engineer in 100 days ――Day 24 ―― Python ―― Basics of Python language 1
I tried to develop a Formatter that outputs Python logs in JSON
You will be an engineer in 100 days ――Day 30 ―― Python ―― Basics of Python language 6
I tried to implement a card game of playing cards in Python
You will be an engineer in 100 days ――Day 25 ―― Python ―― Basics of Python language 2
Generate a first class collection in Python
I tried to implement PLSA in Python
Spiral book in Python! Python with a spiral book! (Chapter 14 ~)
Solve ABC175 A, B, C in Python
Use print in a Python2 lambda expression
A simple HTTP client implemented in Python
I tried to implement permutation in Python
Do a non-recursive Euler Tour in Python
I made a payroll program in Python!
Precautions when pickling a function in python