Neverending Python Challenges Game!

+11 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 wall
10 Green Bottles hanging on the wall
And if one Green Bottle should accidentally fall
There'll be 9 Green Bottles hanging on the wall

9 Green Bottles hanging on the wall
9 Green Bottles hanging on the wall
And if one Green Bottle should accidentally fall
There'll be 8 Green Bottles hanging on the wall


Whoever answer first can post the next challenge!  :happy:

Post a Reply


- page 1
Oldest  Newest  Rating
+4 Emily Cash · August 27, 2014

num = 10
while 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  :)
+3 Tommy Hillis · August 27, 2014
I got this!


fridays = 0

for days in range(1, 366):
    if days % 7 is 5:
        print("Day", days, "is a Friday")
        fridays += 1

print("\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:

+1 Ramanpreet Kaur · August 27, 2014
This works, but I am getting a warning for some reason  :(

ramanpreet = ['Newton', 'House', 'Dog', 'Computer', 'Programming']

# 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 = 17
You have:   J 3 = 13

You lose.
+2 Yoncho Yonchev · August 27, 2014

from random import randint


def count_cards(n):
   if n+2 <=10:
      return n+2
      return 10

print('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!')
   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.
+1 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 them
sen="The quick brown fox jumps over the lazy dog"
for i in range(0,len(alph)):
    for j in range(0,len(sen)):
        while sen[j]==" ":
        if alph==sen[j]:
    if k==0:
        print("Sorry, sentence is not a pangram!")
print("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)
+1 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.
0 Nikola Pantelić · August 27, 2014
Oh... I think I read it wrong! Nevermind, I will edit the code :D
+2 Gary Murphy · August 29, 2014

newNumber = ""
number = str(raw_input("Enter your number: "))
for i in number:
    newNumber = i + newNumber
if number == newNumber:
    print("The number is a palindrome")
    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.
0 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 input
sentence=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 dictionary
def char_histogram(sentence):
    return {sentence.count(ch):ch for ch in set(sentence)}


Program that checks if number is narcissistic (
0 Nikola Pantelić · September 3, 2014
for i in range(0,chars):
if result==int(num):
    print('Number is narcissistic!')
    print('Sorry, number is not narcissistic...')

Make a Rock, Paper, Scissors game!
  • 1
  • 2



This section is all about snakes! Just kidding.

Bucky Roberts Administrator