paizaラーニングのレベルアップ問題集「Cランクレベルアップメニュー 」からの出典です。
paiza.jp
Pythonによる「Cランクレベルアップメニュー 」文字列 問題集と、それらの提出コードの解答例です。
僕が作成、提出したコードは、以下のとおりです。
・STEP: 1 整数と文字列
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 1 整数と文字列 https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 n = int(input()) for i in range(n): s = input() print(len(s))
・STEP: 2 部分文字列
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 2 部分文字列 https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 foo = input() bar = input() if foo in bar: print("YES") else: print("NO")
・STEP: 3 数字の文字列操作(基本)
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 3 数字の文字列操作(基本) https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 n = input() print(str(int(n[0]) + int(n[3])) + str(int(n[1]) + int(n[2])))
・STEP: 4 数字の文字列操作(0埋め)
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 4 数字の文字列操作(0埋め) https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 n = input() if len(n) == 1: print("00" + n) elif len(n) == 2: print("0" + n) else: print(n)
・STEP: 5 数字の文字列操作(時刻1)
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 5 数字の文字列操作(時刻1) https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 s = input().split(":") print(int(s[0])) print(int(s[1]))
・STEP: 6 数字の文字列操作(時刻2)
/* Pythonによる「Cランクレベルアップメニュー 」文字列 問題集 STEP: 6 数字の文字列操作(時刻2) https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 n = input().split(":") m = int(n[1]) + 30 h = int(n[0]) if m >= 60: h = h + 1 m = m - 60 if h < 10: h = "0" + str(h) if m < 10: m = "0" + str(m) print(str(h) + ":" + str(m))
・FINAL問題: 文字列
/* Pythonによる「Cランクレベルアップメニュー 」標準入出力 問題集 FINAL問題: 文字列 https://paiza.jp/works/mondai 提出コードの解答例 https://neguse-atama.hatenablog.com */ # coding: utf-8 n = int(input()) for i in range(n): num = input().rstrip().split() m = int((num[0])[-2:]) + int(num[2]) h = int((num[0])[:2]) + int(num[1]) if m >= 60: h = h + 1 m = m - 60 if h >= 24: h = h - 24 if h < 10: h = "0" + str(h) if m < 10: m = "0" + str(m) print(str(h) + ":" + str(m))
paizaラーニングのレベルアップ問題集については、ユーザー同士で解答を教え合ったり、コードを公開したりするのは自由としています。
また授業や研修、教材などにも利用できるそうです。