热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

面试准备

模拟考试

设为首页

收藏此页面

订阅邮箱地址

Python Coding 面试题与答案

问题 1. Write a function to reverse a string.

def reverse_string(input_str):

return input_str[::-1]

Example:

reverse_string('hello')  # Output: 'olleh'

这有帮助吗? 添加评论 查看评论
 

问题 2. Implement a function to check if a string is a palindrome.

def is_palindrome(input_str):

return input_str == input_str[::-1]

Example:

is_palindrome('radar')  # Output: True

这有帮助吗? 添加评论 查看评论
 

问题 3. Write a Python program to find the factorial of a number.

def factorial(n):

  return 1 if n == 0 else n * factorial(n-1)

Example:

factorial(5)  # Output: 120

这有帮助吗? 添加评论 查看评论
 

问题 4. Implement a function to check if a number is prime.

def is_prime(num):

  if num < 2:

  return False

  for i in range(2, int(num**0.5) + 1):

    if num % i == 0:

      return False

   return True

Example:

is_prime(11)  # Output: True

这有帮助吗? 添加评论 查看评论
 

问题 5. Create a Python class for a basic stack implementation.

class Stack:

  def __init__(self):

    self.items = []

 

  def push(self, item):

    self.items.append(item)

 

  def pop(self):

    return self.items.pop()

 

  def is_empty(self):

    return len(self.items) == 0

Example:

stack = Stack()
stack.push(1)
stack.push(2)
print(stack.pop())  # Output: 2

这有帮助吗? 添加评论 查看评论
 

用户评价最有帮助的内容:

版权所有 © 2026,WithoutBook。