# Neverending Python Challenges Game!

 Aubree Keegan · August 27, 2014 I think that Bucky's challenges are really fun and they are helping me learn too, so here is an idea I just came up with.We will start with a programming challenge. As soon as a user completes that challenge, they will post the answer and also a challenge of their own! This way, we will always have a new problem to work on.Here is my first one:Create a Python program that will complete this song:10 Green Bottles hanging on the wall10 Green Bottles hanging on the wallAnd if one Green Bottle should accidentally fallThere'll be 9 Green Bottles hanging on the wall9 Green Bottles hanging on the wall9 Green Bottles hanging on the wallAnd if one Green Bottle should accidentally fallThere'll be 8 Green Bottles hanging on the wall...Whoever answer first can post the next challenge!

## Replies

- page 1

 Emily Cash · August 27, 2014 ``num = 10while num > 0:    print(num, "Green Bottles hanging on the wall")    print(num, "Green Bottles hanging on the wall")    print("And if one Green Bottle should accidentally fall")    num -= 1    print("There'll be", num, "Green Bottles hanging on the wall\n")``Next challenge: If a year (365 days) starts on a Monday, find out how many Fridays are in that year Tommy Hillis · August 27, 2014 I got this!``fridays = 0for days in range(1, 366):    if days % 7 is 5:        print("Day", days, "is a Friday")        fridays += 1print("\nThere are", fridays, "Fridays this year!")``For the next challenge, let the user input any number, and print a start pyramid with that many rows. For example if they said 5:``    *   ***  ***** ****************`` Ramanpreet Kaur · August 27, 2014 This works, but I am getting a warning for some reason  ``ramanpreet = ['Newton', 'House', 'Dog', 'Computer', 'Programming']ramanpreet.sort(key=len)print(ramanpreet)# output# ['Dog', 'House', 'Newton', 'Computer', 'Programming']``This is my warning:Expected type '(str) -> object | None' (matched generic type '(T) -> object | None'), got '(object: Sized) -> int' instead less... (Ctrl+F1) This inspection detects type errors in function call expressions. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Types of function parameters can be specified in docstrings or in Python 3 function annotations. I don't understand what this means. Can anyone help? And it does work, so here is my next challenge. Create a simple program that randomly deals you and the dealer two cards each. The highest total wins! (the output should look like this)``Dealer has: K 7 = 17You have:   J 3 = 13You lose.`` Yoncho Yonchev · August 27, 2014 ``from random import randintl=[2,3,4,5,6,7,8,9,10,'J','Q','K','A']n1,n2,n3,n4=randint(0,12),randint(0,12),randint(0,12),randint(0,12)def count_cards(n):   if n+2 <=10:      return n+2   else:      return 10print('Dealer has: ' +str(l[n1])+' '+str(l[n2])+'='+str(count_cards(n1)+count_cards(n2)))print('You have: ' +str(l[n3])+' '+str(l[n4])+'='+str(count_cards(n3)+count_cards(n4)))if (n1+n2) <(n3+n4):   print('You win!')else:   print('You loose!')``Program, that check is a sentence is panagram in English -> Example:"The quick brown fox jumps over the lazy dog" - contains all letters of the English alphabet. Nikola Pantelić · August 27, 2014 ``### alph is alphabet### sen is sentence### k is variable used to check if the character doesn't appear (1=char is in sentence,0=char is not in sentence)### I used sen.lower() to convert all characters to lower before comparing themalph="abcdefghijklmnopqrstuvwxyz"sen="The quick brown fox jumps over the lazy dog"k=0sen=sen.lower()for i in range(0,len(alph)):    for j in range(0,len(sen)):        while sen[j]==" ":            j+=1        if alph==sen[j]:            k=1            break    if k==0:        print("Sorry, sentence is not a pangram!")        exit(0)    k=0print("Sentence is pangram!")``Type a program that checks if the number is palindrome! Example: Numbers 1221 and 467764 are palindromes (they are same when you read them from behind) Eugene Botma · August 27, 2014 Nikola, a panagram is a sentence that uses all of the letters in the alphabet, repeating letters doesn't matter. Nikola Pantelić · August 27, 2014 Oh... I think I read it wrong! Nevermind, I will edit the code Gary Murphy · August 29, 2014 ``newNumber = ""number = str(raw_input("Enter your number: "))for i in number:    newNumber = i + newNumberif number == newNumber:    print("The number is a palindrome")else:    print("The number is not a palindrome")``Write a piece of code that takes in any string and returns the most used character in that string. Yoncho Yonchev · September 1, 2014 Anything more challenging will be nice. Providing alternative solutions for old tasks is fine too. ``# Python 3.4, authour: yonchoy# removing whitespaces from the inputsentence=str(input()).replace(" ", "")# creating dictionary containing how many times each letter exist, unfortunately doesnt work for dublicates#will show the last entered with the same key in the dictionarydef char_histogram(sentence):    return {sentence.count(ch):ch for ch in set(sentence)}my_dic=char_histogram(sentence)print(my_dic[max(my_dic.keys())])``Program that checks if number is narcissistic (http://en.wikipedia.org/wiki/Narcissistic_number) Nikola Pantelić · September 3, 2014 ``num=371num=str(num)chars=len(num)result=0for i in range(0,chars):    result+=int(num)**charsif result==int(num):    print('Number is narcissistic!')else:    print('Sorry, number is not narcissistic...')``Make a Rock, Paper, Scissors game!
• 1
• 2

## Python

126,613 followers