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 Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube