返回卡包市场

Programming (Topic 6 and Topic 7)

暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。

卡片总数: 21内容版本: v4公开卡包更新时间: 8/1/2026

卡片预览 (21 张)

#1
正面 (问题)

What is Binary Search?

背面 (解答)

A search algorithm for sorted lists that divides the list into halves to find a target.

#2
正面 (问题)

How does Binary Search work?

背面 (解答)

• Compare the middle element to the target. • Search left or right based on the target. • Repeat.

#3
正面 (问题)

What is Linear Search?

背面 (解答)

A search algorithm that checks each element one by one until the target is found or list ends.

#4
正面 (问题)

When is Linear Search useful?

背面 (解答)

For small or unsorted lists.

#5
正面 (问题)

How does Bubble Sort work?

背面 (解答)

• Compare two adjacent items. • Swap if wrong order. • Repeat for the whole list.

#6
正面 (问题)

What is the main disadvantage of Bubble Sort?

背面 (解答)

It is slow for large lists because it repeatedly checks all elements.

#7
正面 (问题)

How does Insertion Sort work?

背面 (解答)

• Start with one item as “sorted.” • Insert the next item into its correct position. • Repeat.

#8
正面 (问题)

How does Merge Sort work?

背面 (解答)

• Divide the list into smaller sublists. • Merge the sublists back in sorted order.

#9
正面 (问题)

What is a While Loop?

背面 (解答)

A loop that runs as long as a condition is true. Example: while x < 5: print(x)

#10
正面 (问题)

What is a For Loop?

背面 (解答)

A loop that iterates over a sequence (list or range). Example: for i in range(5): print(i)

#11
正面 (问题)

What is an If Statement?

背面 (解答)

A decision-making construct that runs code based on a condition. Example: if x > 0: print(“Positive”)

#12
正面 (问题)

What is an Array?

背面 (解答)

A collection of items stored in a single variable (lists in Python). Example: numbers = [1, 2, 3]

#13
正面 (问题)

What is a Function?

背面 (解答)

A reusable block of code designed for a specific task. Example: def greet(name): return f”Hello, {name}!”

#14
正面 (问题)

What is a Subroutine?

背面 (解答)

Another term for a function or method used for specific tasks in a program.

#15
正面 (问题)

What are Parameters in Functions?

背面 (解答)

Variables in the function header to take inputs. Example: def add(x, y): return x + y

#16
正面 (问题)

What is Basic File Handling?

背面 (解答)

Operations to read from and write to files in Python. Modes: “r” (read), “w” (write), “a” (append).

#17
正面 (问题)

How do you write to a file in Python?

背面 (解答)

with open(“file.txt”, “w”) as file: file.write(“Hello, world!”)

#18
正面 (问题)

How do you read a file in Python?

背面 (解答)

with open(“file.txt”, “r”) as file: content = file.read()

#19
正面 (问题)

What is SQL?

背面 (解答)

Structured Query Language, used to manage and query databases.

#20
正面 (问题)

What are common SQL commands?

背面 (解答)

SELECT (retrieve), INSERT (add), UPDATE (modify), DELETE (remove).

#21
正面 (问题)

How do you connect Python to a database?

背面 (解答)

Use sqlite3 for simple databases: import sqlite3; conn = sqlite3.connect(“example.db”)