Pythonコーディング演習問題集: 初級~中級編
Practice coding with 30 exercises! Test your grammar & algorithm knowledge and solidify your skills. Improve your programming abilities.
Course Content
Pythonコーディング演習問題集: 初級~中級編 is a beginner-level Udemy course taught by イクマ ヒロユキ. It runs 30m, is taught in Japanese, and includes a certificate of completion. Learners rate it 4.1 out of 5 from 55 reviews, with 886 students enrolled. It is a paid course, first published July 2024.
Python Coding Exercises: Fundamental Algorithms & Data Structures
This set of 30 coding exercises focuses on core Python concepts and fundamental algorithms. Practice your Python programming skills with these challenges covering:
- Data Types: Deepen your understanding of types in Python.
- Control Flow: Master conditional statements (
if,else) and looping (for,while) for efficient code. - Operators: Learn to effectively utilize operators (arithmetic, comparison, logical).
- String Manipulation: Develop skills in working with strings in Python.
- List Operations: Practice common list operations (accessing, modifying, filtering).
- Dictionary Operations: Gain proficiency in using dictionaries for data storage and retrieval.
- Function Definition: Learn to create reusable functions in Python.
- Exception Handling: Implement robust code with exception handling (
try,except). - Class Definition: Understand object-oriented programming with class definition.
- Lambda Expressions: Utilize concise lambda expressions for functional programming.
Beginner Level Examples
Example 1: Find the Longest Word
Implement the find_longest_word(sentence) function to identify the longest word in a given sentence.
- The function should return the longest word as a string.
- The sentence is passed as an argument.
- Word separation is based on single spaces.
- If multiple words have the same maximum length, return the first one encountered.
def find_longest_word(sentence):
# Your code here
Example Usage:
print(find_longest_word("Python is a programming language")) # Output: programming
print(find_longest_word("Hello World")) # Output: Hello
print(find_longest_word("One two three four five")) # Output: three
Example 2: Is a Number Prime?
Create the is_prime(num) function to determine if a given integer is a prime number.
- The function should return "Prime" if the number is prime, and "Not Prime" otherwise.
- A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
- 2 is the only even prime number.
- 1 is not a prime number.
def is_prime(num):
# Your code here
Example Usage:
print(is_prime(17)) # Output: Prime
print(is_prime(18)) # Output: Not Prime
print(is_prime(19)) # Output: Prime
Intermediate Level Examples
Example 1: Maximum Product Subarray
Given a list of integers nums, create the max_product_subarray(nums) function to find the maximum product of a contiguous subarray.
- A subarray is a continuous sequence of elements within the list.
- Consider the example list
[2, -5, -2, -4, 3]. The subarray[2, -5, -2]is a contiguous subarray, but[-5, -4]is not (due to the-2in between). - The function should return the largest product found among all contiguous subarrays.
def max_product_subarray(nums):
# Your code here
Example Usage:
nums = [2, 3, -2, 4]
print(max_product_subarray(nums)) # Output: 6 (2 * 3)
nums = [-2, 0, -1]
print(max_product_subarray(nums)) # Output: 0 (-2 * 0 and 0 * -1)
nums = [2, -5, -2, -4, 3]
print(max_product_subarray(nums)) # Output: 24 (-2 * -4 * 3)
Example 2: Assign Boarding Gates
You are managing airport boarding gates. Given a list of flight schedules (departure and arrival times as tuples), implement the assign_boarding_gates(flight_schedules) function to determine the minimum number of boarding gates required.
- Each flight occupies a gate from its arrival time until its departure time.
- No two flights can use the same gate simultaneously.
- The function should return the minimum number of gates needed.
def assign_boarding
Need a web app built? Hire the team behind TutorialSearch.io
We ship fast, production-grade full-stack apps (Next.js, React, edge infra) — the same stack that powers this site.