Loading...
Main Page → Exercises → Python
Click a category below to view its available exercises.
Python (679)
- Programming practice in Python at a CS1 (first-course) introductory level.
-
algorithms (14)
- These are miscellaneous problems involving various concepts and algorithms. These are intentionally not categorized by concepts (such as list, string, tree, recursion, etc.) so that you must consider for yourself the best way to solve the problem. This category might be useful when studying for a coding interview.
- baggage_colors
- baggage_colors2
- binary_boarding
- binary_boarding2
- passports
- passports2
- sum_of_2020
- sum3_of_2020
- surveys
- surveys2
- threeSum
- toboggan
- toboggan2
- valid_passwords
- valid_passwords2
-
assertions (5)
-
bigoh (3)
-
classes (20)
-
collections (156)
-
list (92)
- all_less
- average
- average_length
- banish
- check_balance
- collapse
- collapse_pairs
- compute_average
- contains
- copy_column
- count_duplicates
- count_unique
- data_list
- double_list
- fill_data_list
- find_median
- find_range
- find_range_2d
- five_by_ten_list
- flip_half
- get_percent_even
- has_mirror_twice
- index_of
- is_magic_square
- is_palindrome
- is_sorted
- is_stack_sorted
- jagged_list
- list_declare
- list_expressions
- list_mystery1
- list_mystery2
- list_mystery2_xy
- list_mystery3_xy
- list_mystery_1_pop_insert
- list_mystery_2_mod2_insert
- list_mystery_2d
- list_mystery_ab
- list_range
- list_tracing_2d
- longest_sorted_sequence
- loop_tracing
- loop_tracing2
- loop_tracing3
- matrix_add
- max_value
- maximum
- mean
- median
- min_to_front
- mirror
- mode
- mystery1
- mystery2
- mystery2d
- n_copies
- nearest_points
- num_unique
- number_elements
- numbers_list
- odds_list
- pixel_list_dimensions
- price_is_right
- print_elements
- print_list
- rectangular_list
- reference_mystery1
- reference_mystery2
- reference_mystery2_xa_lis
- reference_mystery3
- reference_mystery4
- reference_mystery5
- reference_mystery_xa
- remove_all
- remove_duplicates
- remove_even_length
- remove_palindromes
- reorder
- repeat
- scale_by_k
- slice_expressions
- sorted
- split
- split_stack
- stormy
- stormy2
- stormy3
- stutter
- swap_pairs
- switch_pairs
- traversal
- tuple_errors
- vowel_count
-
dict (46)
- area_codes
- biggest_family
- by_age
- collection_mystery1
- collection_mystery2
- collection_mystery3
- collection_mystery4
- collection_mystery5
- collection_mystery6
- collection_mystery7
- collection_mystery8
- collection_mystery9
- collection_mystery10
- count_names
- deans_list
- dict_mystery
- friend_list
- get_majority_last_name
- has_duplicate_value
- has_three
- intersect
- is_sub_dict
- is_unique
- last_names_by_age
- least_common
- max_occurrences
- pair_frequencies
- postal_service
- rarest
- rarest_age
- reverse
- starters
- teacher
- to_morse_code
- word_chain
- is_1_to_1
- dict_comprehensions
- dict_concepts
- dict_declare_names_ages
- dict_mystery1
- dict_mystery2
- dict_mystery3
- dict_mystery4
- dict_tracing1
- dict_tracing2
- start_letters
-
set (18)
-
-
console output (51)
- archie
- arrows
- calculate_line
- confounding
- difference
- doubleslash
- downward_spiral
- emergency_broadcast
- egg
- egg2
- egg_stop
- escape1
- escape2
- even_average
- even_sum_max
- fear_the_tree
- fight_song
- function_header
- hello_world
- inches_to_centimeters
- input_average_3
- legal_identifiers
- mantra
- output_syntax
- print_program
- print_slashes
- receipt
- receipt2
- sally
- shaq
- speak_friend
- spikey
- stanford_vs_cal
- star_figures
- stewie
- stewie2
- strange
- strange2
- strange3
- surely_no_errors
- test_of_knowledge
- towers
- tricky
- two_rockets
- well_formed
- old_lady
- six_days
- bought_me_a_cat
- jack_built
- ta_just_smiled
- cs_rap
- cs_rap2
-
expressions (26)
- compute_pay
- define_grade_variable
- expressions_exam1
- expressions_exam2
- expressions_exam3
- expressions_exam4
- expressions_exam5
- expressions_exam6
- expressions_mix1
- expressions_mix2
- expressions_number1
- expressions_number2
- expressions_numbers37
- expressions_numbers1_at
- expressions_numbers2_ar
- first_second
- first_second2
- four_mistakes
- last_digit
- max_min
- random_integer_0_to_10
- random_odd_integer_50_to_99
- roundoff_error
- second_to_last_digit
- values_of_abc
- values_of_ijk
-
file input output (45)
- ask_file_name
- average_value_in_file
- boy_girl
- check_dates
- class_presidents
- coin_flip
- collapse_spaces
- coolest
- count_coins
- election
- even_numbers
- flip_and_reverse_lines
- flip_coins
- flip_lines
- get_file_name
- hours
- how_to_read_a_file
- input_stats
- leet_speak
- most_common
- negative_sum
- pig_latin
- pig_latin2
- plus_scores
- print_box
- print_entire_file
- print_entire_file2
- print_most_common_name
- print_myself
- read_input_txt
- readme
- readme2
- relative_paths
- relative_paths2
- remove_duplicates_from_file
- reverse_chunks_in_file
- split_return
- split_return2
- weather
- word_stats
- word_stats_plus
- word_wrap
- word_wrap2
- word_wrap3
- write_four_lines
-
functional programming (19)
- Exercises focused on Python's functional programming constructs like list comprehensions, generator expressions, map, filter, and reduce.
- abs_sum
- count_negatives
- count_vowels
- double_list
- four_letter_words
- functional_concepts
- generate_odds
- glue_reverse
- lambda_concat_name
- lambda_larger
- lambda_square
- lambda_tracing
- lambda_tracing2
- largest_even
- pig_latin
- print_40_char_lines
- the_lines
- three_four_letter_words
- total_circle_area
-
graphics (17)
- Graphical programming using the DrawingPanel library written by Marty Stepp and Allison Obourn.
- draw_black_white_rectangle
- draw_line_errors
- draw_rectangle_syntax
- drawing_appearance
- face
- face2
- mickey_box
- mickey_box2
- show_design
- show_design2
- stairs
- stairs2a
- stairs2b
- stairs2c
- circles
- cafe_wall
- projectile2
-
if else (37)
- Exercises related to if/else statements and boolean logic.
- assertions_1
- assertions_2
- assertions_3
- contribution
- count_factors
- days_in_month
- divisible_by_6
- enough_time_for_lunch
- even_sum_max
- factoring_awesome
- fraction_sum
- get_grade
- has_pennies
- has_midpoint
- if_else_mystery1
- if_else_mystery2
- if_else_mystery_1
- if_else_mystery_2
- if_else_translation
- input_color
- input_even_odd
- is_prime
- is_vowel
- logical_expressions
- logical_expressions_de_morgans
- longest_name
- median_of_3
- minimum_mistakes
- month_apart
- percentage_grade
- print_num_odd
- print_num_range
- print_triangle_type
- relational_expressions
- roundoff_credits
- smallest_largest
- start_end_same
- xo
-
loops (89)
- ascii_figure
- ascii_figure2
- armstrong_numbers
- biggest_and_smallest
- blastoff
- cheerleader
- complete_loop
- compute_sum_of_digits
- count_even_digits
- dice_sum
- digit_sum
- fibonacci_sequence
- finger_trap
- first_digit
- five_to_five
- fizzbuzz
- flip_coin_three_heads
- floyds_triangle
- for_to_while
- gcd
- guessing_game
- guess2d
- is_all_vowels
- loop_mystery_exam1
- loop_mystery_exam3
- loop_mystery_exam5
- loop_mystery_print1
- loop_squares
- loop_table
- loop_table2_constant
- loop_times
- multiplication
- number_loops1
- number_loops2
- number_loops
- number_square
- number_total
- number_triangle
- odd_stuff
- piglet
- print_average
- print_design
- print_factors
- print_grid
- print_letters
- print_numbers1
- print_numbers2
- print_numbers3
- print_pyramid
- print_square
- print_triangle2
- print_triangle
- print_wave
- random_rects
- random_walk
- random_x
- range_of_numbers
- robust_input
- roll_two_dice
- sentinel_min_max
- sentinel_sum
- show_twos
- slash_figure2
- slash_figure2_loop_table
- slash_figure
- slash_figure_loop_table
- spaced_numbers
- spaced_numbers2
- squares
- star_square
- star_triangle
- stars_print
- sum_to
- swap_digit_pairs
- three_heads
- to_binary
- triply_nested
- while_loops
- while_mystery_1
- while_mystery_2
- while_mystery_3
- window
- zune_bug
- rocket
- rocket2
- space_needle
- space_needle2
- book
- book2
-
parameters and return (73)
- area
- average_of_2
- average_of_3
- binary_to_decimal
- birthday
- bmi
- box_of_stars
- carbonated
- circle_area
- coin_flip
- compute_distance
- count_digits
- count_quarters
- count_unique
- days_in_month
- decimal_to_binary
- expressions_math
- factor_count
- factorial
- fitness_goal
- ftoc
- get_days_in_month
- get_first_digit
- get_last_digit
- grade_count
- grades
- half_the_fun
- investment
- is_multiple
- is_prime_number
- larger_abs_val
- last_digit
- mystery_xyz
- pad_string
- parameter_mystery1
- parameter_mystery2
- parameter_mystery_exam1
- parameter_mystery_exam2
- parameter_mystery_exam3
- parameter_mystery_exam4
- parameter_mystery_exam5
- parameter_mystery_exam6
- parameter_mystery_section1
- parameter_mystery_section2
- pay
- play_roulette
- print_last_digit
- print_number_square
- print_numbers
- print_odds
- print_pay
- print_powers_of_2
- print_powers_of_n
- print_random
- print_stars
- print_strings
- projectile
- quadratic
- random_over
- random_walk
- retirement
- return_mystery1
- robert_paulson
- roulette
- sentence_num
- sentence_whom
- show_twos
- sphere_volume
- sum_of_digits
- sum_of_range
- sum_up_to
- three_consecutive
- times2
- touch
- triangle
- vertical
-
recursion (67)
- collapse_sequences
- count_to_by
- crawl
- digit_match
- digit_sum
- digits_sorted
- double_digits
- double_reverse
- edit_distance
- even_digits
- factorial
- fibonacci
- fractal_concepts
- hanoi
- hash_string
- index_of
- is_palindrome
- is_reverse
- is_subsequence
- match_count
- merge_digit_pairs
- mirror_sequence
- move_to_end
- mystery1
- non_matching
- number_sequence
- power
- power_concepts
- print_binary
- print_range
- print_stars
- recursion_concepts
- recursion_mystery10
- recursion_mystery1
- recursion_mystery1_x
- recursion_mystery2
- recursion_mystery2_x
- recursion_mystery348
- recursion_mystery3
- recursion_mystery4
- recursion_mystery5
- recursion_mystery648
- recursion_mystery6
- recursion_mystery7
- recursion_mystery8
- recursion_mystery9
- recursion_mystery_comma
- recursion_mystery_div10
- recursion_mystery_div2
- recursion_mystery_div_mod
- recursion_mystery_minus
- recursion_mystery_print_digits
- recursion_mystery_times2
- remove_odd_digits
- repeat_string
- replace_all
- reverse
- reverse_lines
- sequence
- star_string
- stutter_list
- sum_of_squares
- sum_up_to
- write_binary
- write_chars
- write_nums
- write_sequence
- zigzag
-
backtracking (8)
- Exercises related to recursive backtracking and exhaustive search.
- backtracking_concepts
- count_binary
- eightqueens_concepts
- max_sum
- subsets
- travel
- travel_concepts
- ways_to_climb
-
searching (10)
-
sorting (8)
-
strings (31)
- add_commas
- caesar_cipher
- contains_twice
- convert_to_alt_caps
- count_words
- dna_errors
- dracula
- is_all_vowels
- is_palindrome
- is_rotation
- is_vowel
- last_first
- marshall_mathers
- name_diamond
- name_game
- print_backward
- print_palindrome
- print_range
- remove_all
- remove_duplicates
- repeat
- reverse
- reverse_chunks
- reverse_word_order
- same_dashes
- second_half_letters
- start_end_letter
- startswith_uppercase
- stutter
- switch_pairs
- word_count
You must log in before you can search for exercises or top users.
Is there a problem? Contact us.