Skip to content

Instantly share code, notes, and snippets.

@BjoernSchilberg
Last active June 12, 2020 18:55
Show Gist options
  • Save BjoernSchilberg/e616c61f9ca91bdb994d to your computer and use it in GitHub Desktop.
Save BjoernSchilberg/e616c61f9ca91bdb994d to your computer and use it in GitHub Desktop.
Programmieraufgaben fizzbuzz & co

Programmieraufgaben

Fizzbuzz

for i in xrange(1, 101):
    if i % 15 == 0:
        print "FizzBuzz"
    elif i % 3 == 0:
        print "Fizz"
    elif i % 5 == 0:
        print "Buzz"
    else:
        print i

Returning only the max odd integer in a list

mylist = [-10, -11, 4, 3, 7, 2, 8, 3]
max(i for i in mylist if i % 2 == 1)

Returning only the max even integer in a list

mylist = [-10, -11, 4, 3, 7, 2, 8, 3]
max(i for i in mylist if i % 2 == 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment