Skip to content

Instantly share code, notes, and snippets.

import yt_dlp
def download_video_audio(url):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
@kevin-weitgenant
kevin-weitgenant / Fibonacci.py
Created August 4, 2016 23:54
practicepython.org Exercise 13
def x(number):
fibonacci = [1, 1]
for _ in range(number-2):
last = len(fibonacci) - 1
penultimo = len(fibonacci) - 2
resultado = int(fibonacci[last]) + int(fibonacci[penultimo])
fibonacci.append(resultado)
return fibonacci
@kevin-weitgenant
kevin-weitgenant / first_and_last.py
Created August 4, 2016 19:13
practicepython.org exercise 12
def first_and_last():
a, *b, c = [5, 10, 15, 20, 25]
return print(a, "and ", c)
first_and_last()
@kevin-weitgenant
kevin-weitgenant / prime_or_not.py
Created August 4, 2016 19:07
practicepython.org Exercise 11
def prime_or_not(number):
z = 0
for x in range(number):
x += 1
if number % x == 0:
z += 1
return z
@kevin-weitgenant
kevin-weitgenant / list-overlap-comprehensions.py
Created August 4, 2016 19:06
practicepython.org Exercise 10
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c = list({x for x in a if x in b})
print(c)
@kevin-weitgenant
kevin-weitgenant / Guessing Game One.py
Created August 3, 2016 21:57
practicepython.org Exercise 09
import random
a = random.randint(1, 9)
x = ""
while x != "exit":
user_number = int(input("Choose a number between 1 and 9:"))
if a > user_number:
print("Too low!")
@kevin-weitgenant
kevin-weitgenant / Rock Paper Scissors
Created August 3, 2016 21:38
practicepython.org Exercise 08
x = "1"
while x == "1":
player1 = input("Player 1, Choose Rock, Scissors or Paper:")
player2 = input("Player 2, Choose Rock, Scissors or Paper:")
if player1 == player2:
print("Draw!")
@kevin-weitgenant
kevin-weitgenant / List_Comprehensions.py
Created August 3, 2016 10:35
practicepython.org Execise 07
even = [x for x in [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] if x % 2 == 0]
@kevin-weitgenant
kevin-weitgenant / String_Lists
Created August 2, 2016 14:21
practicepython.org Exercise 06
a = input("Say something:")
number = int(len(a))
for x in range(number):
if a[x] == a[-(x + 1)]:
continue
else:
print("Isn't a palindrome")
break
@kevin-weitgenant
kevin-weitgenant / List_Overlap.py
Created August 2, 2016 13:17
practicepython.org Exercise 05
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
c = []
for x in a:
if x in b:
if x in c:
continue
c.append(x)
print(c)