Hello there DANIWEB!

Now I know that there are already many different discussions asking for python ideas for beginners, but I thought maybe this could be a discussion for all different abilities. For example, if I wanted to reply with a Beginner idea, I would type:

BEGINNER

And the same for INTERMEDIATE and EXPERT.
That way, if anybody of those three levels tries to look for something, all they have to do is ctrl+f and type in beginner, intermediate, or expert!

Many thanks!
Jet

## All 12 Replies

BEGINNER
Hey again, I thought to start this discussion off, I could post an idea of my own. I did a simple calculator, copied from a book. Thought it might help some people to start.

``````name=raw_input("What is your name?")
print"Welcome to the program,",name
again=1
while again==1:
first=int(raw_input("Type the first number:\n> "))
second=int(raw_input("Type the second number:\n> "))

print first,"minus",second,"equals",first-second
print(first,"multiplied by",second,"equals",first*second

again=int(raw_input("Type 1 to enter more numbers, or any other    number to quit:\n> ")
``````

I hope this is alright for you all. You can add in division, or extra addition, multiplication, subtraction, or division by reversing the variables 'second' and 'first' in the print statements.

Open for feedback...
Many thanks!
Jet

INTERMEDIATE
Hi,
maybe you could add some functionality to the program by giving the user the option of which maths you want the program to complete.

``````name=raw_input("What is your name?")
print"Welcome to the program,",name
again=1
while again==1:
Choice=int(raw_input("Press 1 for addition 2 for subtraction or 3 for multiplication"))
first=int(raw_input("Type the first number:\n> "))
second=int(raw_input("Type the second number:\n> "))
if Choice == 1:
elif Choice == 2:
print first,"minus",second,"equals",first-second
elif Choice == 3:
print first,"multiplied by",second,"equals",first*second
again=int(raw_input("Type 1 to enter more numbers, or any other number to quit:\n> ")
``````

Lemon

commented: Well done! Very good idea. Many thanks! +0
``````''' filename_list_given_dir1.py
use module glob to list all the filenames of .jpg files
or any extension(s) you specify in a given directory
'''

import glob
import os

# all files (split off file names) in a given directory
directory = "C:/Temp/*.jpg"
# this would give you all files
#directory = "C:/Temp/*.*"
for path in glob.glob(directory):
#print(path)  # test
# separate path from filename
dirname, filename = os.path.split(path)
print(filename)
``````

Challenge, how would you show all .py and .txt files in a given directory?

commented: Is this the right place to be posting this? +0

@ZZucker Perhaps you shouldn't have posted this here.... Wrong topic?

Beginner
Hey there. Just an idea based on one from another discussion.

``````import random
#imports random library

a=random.randint(1,11)
b=random.randint(1,11)
c=random.randint(1,11)

if a==1:
text1="An adjective and a noun e.g A happy camel"
elif a==2:
elif a==3:
elif a==4:
elif a==5:
elif a==6:
elif a==7:
elif a==8:
elif a==9:
elif a==10:
elif a==11:

if b==1:
text2="a verb and adverb e.g brutally murders"
elif b==2:
elif b==3:
elif b==4:
elif b==5:
elif b==6:
elif b==7:
elif b==8:
elif b==9:
elif b==10:
elif b==11:

if c==1:
if c==2:
text3="a noun.
if c==3:
text3="a noun.
if c==4:
text3="a noun.
if c==5:
text3="a noun.
if c==6:
text3="a noun.
if c==7:
text3="a noun.
if c==8:
text3="a noun.
if c==9:
text3="a noun.
if c==10:
text3="a noun.
if c==11:

print(text1,text2,text3)
text3="a noun.
``````

Replace where appropriate, doesn't have to be 11, can be any number.

Many thanks!
Jet

Beginner
Edit for the above

``````import random
#imports random library
a=random.randint(1,11)
b=random.randint(1,11)
c=random.randint(1,11)
if a==1:
text1="An adjective and a noun e.g A happy camel"
elif a==2:
elif a==3:
elif a==4:
elif a==5:
elif a==6:
elif a==7:
elif a==8:
elif a==9:
elif a==10:
elif a==11:
if b==1:
text2="a verb and adverb e.g brutally murders"
elif b==2:
elif b==3:
elif b==4:
elif b==5:
elif b==6:
elif b==7:
elif b==8:
elif b==9:
elif b==10:
elif b==11:
if c==1:
if c==2:
text3="a noun."
if c==3:
text3="a noun."
if c==4:
text3="a noun."
if c==5:
text3="a noun."
if c==6:
text3="a noun."
if c==7:
text3="a noun."
if c==8:
text3="a noun."
if c==9:
text3="a noun."
if c==10:
text3="a noun."
if c==11:
print(text1,text2,text3)
``````

Many thanks!
Jet

@Gribouillis What do you mean? Be more specific otherwise I can't improve... :/

Learn, listen, logic.

@ZZucker What?! You're going to have to speak straight.

One that's currently linked in my signature.

Beginner-Intermediate

The graph on the left is said to be two-colourable (or bipartite), because you are able to colour the nodes with two colours such that no adjacent nodes are the same colour.
It is impossible to colour the graph on the right with two colours such that no adjacent nodes share the same colour. Thus, it is not two-colourable.

Out of all possible graphs with 7 nodes, how many are two-colourable?

Expert

PyEditor1.0

``````from Tkinter import*
import tkDialog as tk_Dialog
from Stringl0 import Stringl0
import os
recents = []

class PyEditor:
def doNew(self):
self.text.delete(0.0,END)

def doUndo(self):
self.text.edit_undo()

def doSaveAs(self):
textoutput = self.text.get(0.0,END)
file.write(textoutput.rstrip())
file.write('\n')

def doOpen(self):
file = tk_FileDialog(mode='r')
recents.append(file)

self.text.delete(0.0,END)
self.text.insert(0.0,fileContents)

def doRun(self):
os.system('c:\\Python25\\python ' + file.name)

def __init__(self):
self.root = Tk()
self.root.title('PyEditor1.0')
self.root.minsize(with=800,height=535)