@Gribouillis hi and thanks for the improvement , originally that is what I had in mind but I tried and tried but could not get the rest of the code working ( your while true part line 20 and after , but my version) until I got headache looking at the monitor that is why I cut my code short and uploaded the short version . I will look at your code again once my headache is gone . thanks again

Pygame can do it ...

import pygame as pg

pg.init()
yellow = (255, 255, 0)
screen = pg.display.set_mode((640, 280))
# pick a font you have and set its size
myfont = pg.font.SysFont("Courier", 60)
label = myfont.render("Hello World", 1, yellow)
screen.blit(label, (100, 100))
pg.display.flip()

# event loop used for exit
while True:
    for event in pg.event.get():
        # exit conditions --> windows titlebar x click
        if event.type == pg.QUIT:
            pg.quit()
            raise SystemExit

Hello world on the wall?
This is a rewite of some code i did for a "99 bottles of beer" challenge.
Use Google image API and take out some random images.
Use IPython Notebook to show result.
Here some result.
Hello world
Hello World Python
Hello World Linux

Unscramble this ...
scramble = "lelHo dorlW"

I thought it might be interesting to show a typical Hello World program in several popular languages, adding a for loop to the fray. Since the C based languages have a main() entrypoint, I added a main() function to the Python code too.

Here is the Python code ...

# py_hello_world_loop.py

def main():
    for k in range(10):
        print("Hello World")

main()

Followed by the C# (Csharp) code ...

// cs_hello_world_loop.cs

using System;

class Hello
{
    public static void Main()
    {
        for (int k = 0; k < 10; k++)
        {
            Console.WriteLine("Hello World");
        }

    }
}

Now the mighty C++ code ...

// cpp_hello_world_loop.cpp

#include <iostream>

using namespace std;

int main()
{

  for(int k = 0; k < 10; k++)
    cout << "Hello World" << endl;

}

One of the classic languages C ...

// c_hello_world_loop.c

#include <stdio.h>

int main(void)
{
   int k;

   for(k = 0; k < 10; k++)
      puts("Hello World\n");

   return 0;
}

Now a relatively new language, Google's Go language ...

// go_hello_world_loop.go

package main

import "fmt"

func main() {

    for k := 0; k < 10; k++ {
        fmt.Println("Hello World")
    }

}

From a dictionary ...

# makes Python3 print() work with Python2
#from __future__ import print_function

d = {0: 'H', 1: 'e', 2: 'l',
3: 'l', 4: 'o', 5: ' ', 6: 'W',
7: 'o', 8: 'r', 9: 'l', 10: 'd'}

for n in range(11):
    print(d[n], end="")

Create the dictionary this way ...
d = dict(enumerate("Hello World"))

From a generator ...

def hello_g():
    yield 'Hello'
    yield 'World'

g = hello_g()
print("{} {}".format(next(g), next(g)))

Concatenate ...

s1 = "Hell"
s2 = "o Wo"
s3 = "rld"
print(s1 + s2 + s3)

From a decorator ...

def hello(func):
    def inner():
        print("Hello World")
        return func
    return inner

@hello
def my_func():
    pass

my_func()

Extract from sentences ...

s1 = "He eats large lunches often."
s2 = "We omit repeating last dates."
s3 = "".join(w[0] for w in s1.split())
s4 = "".join(w[0] for w in s2.split())
print("{} {}".format(s3, s4))

Vegaseat:
Bit more interesting content decorator:

def print_it(func):
    def inner(*args):
        print(' '.join(func()))
        return func
    return inner

@print_it
def my_func():
    return "Hello", "World"

my_func()

Why not?

import textwrap

s = "Hello World " * 5
print(s)
print(textwrap.fill(s, 12))
print(s)

We don't use rjust() too often ...

s = "Hello World:" * 10
n = 10
for w in s.split(':'):
    print(w.rjust(n))
    n += 5

Module kivy ( http://kivy.org/#home ) anyone?

from kivy.app import App
from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout

class TestApp(App):
    def build(self):
        s1 = "drag me with the left mouse button "
        s2 = "or your finger on a touch screen"
        App.title = s1 + s2
        # this will be the root widget to return
        flo = FloatLayout()
        # allows dragging
        scatter = Scatter()
        s = "Hello World"
        label = Label(text=s, font_size=150)

        flo.add_widget(scatter)
        scatter.add_widget(label)
        return flo

TestApp().run()

Let's revisit the generator ...

# makes Python3 print() work with Python2
from __future__ import print_function

# use a generator
def hello_gen():
    for c in "Hello World":
        yield c

g = hello_gen()

while True:
    try:
        print(next(g), end='')
    except StopIteration:
        print('')
        break

# a for loop takes care of StopIteration
for c in hello_gen():
    print(c, end='')
print('')

A little overkill in this case, but it shows the workings of a generator.

You can of course use a generator expression to create a generator ...

gen = (c for c in "Hello World")

while True:
    try:
        print(next(gen), end='')
    except StopIteration:
        print('')
        break

Using module base64 ...

import base64
encoded = "SGVsbG8gV29ybGQ="
try:
    # Python2
    decoded = base64.decodestring(encoded)
except TypeError:
    # Python3
    decoded = base64.decodestring(encoded.encode("utf8")).decode("utf8")
print(decoded)

Making hello world movie with great MoivePy
Results can be seen here

This make a 10 sec long videoclip showing hello world,using codec H264.

import moviepy.editor as moviepy

hello_world = moviepy.TextClip('Hello World!',font="Amiri-bold", fontsize=100, color='blue', size=(800,600))
hello_world = hello_world.set_duration(10)
hello_world.write_videofile('hello_world.avi', fps=24, codec='libx264')

Here a circle fade to text The End.

from moviepy.editor import *
from moviepy.video.tools.drawing import circle

clip = VideoFileClip("hello_world.avi", audio=False).\
           subclip(0,10).\
           add_mask()
w,h = clip.size

# The mask is a circle white vanishing radius r(t) = 800-200*t
clip.mask.get_frame = lambda t: circle(screensize=(clip.w,clip.h),
                                       center=(clip.w/2,clip.h/4),
                                       radius=max(0,int(800-200*t)),
                                       col1=1, col2=0, blur=4)

the_end = TextClip("The End", font="Amiri-bold", color="red",
                   fontsize=200).set_duration(clip.duration)
final = CompositeVideoClip([the_end.set_pos('center'),clip],
                           size =clip.size)
final.write_videofile('the_end.avi', fps=24, codec='libx264')

New words:

tup = ('ello World','uello World')
print('\n'.join(chr(n)+tup[chr(n)=='Q']for n in range(66, 91)))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.