Python Classroom notes 03/Sep/2024

Workshop

Exercise 24: Check for a Pangram

  • Problem: Write a function is_pangram(s) that checks whether a given string s is a pangram (contains every letter of the alphabet at least once).
  • Expected Output:
    python
    is_pangram("The quick brown fox jumps over the lazy dog")
    # Output: True

Exercise 25: Find the Second Largest Element

  • Problem: Write a function second_largest(lst) that returns the second largest element in a list of integers.
  • Expected Output:
    python
    second_largest([10, 20, 4, 45, 99])
    # Output: 45

Exercise 20: Generate a List of Primes

  • Problem: Write a function generate_primes(n) that returns a list of prime numbers up to n.
  • Expected Output:
    python
    generate_primes(10)
    # Output: [2, 3, 5, 7]
  • Refer Here for notebook used in class
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%