Some simple python programming

Hi there,
Well programming in python is easy and also funn.
Im posting this code, because I am not using anymore my old blog that I used just for python.
So I thought it would be better to transfer all those things here.
Below is My firs code ever in python.
Its very simple, (just a conversation with the computer)

#!/usr/bin/python

print 'Enter your name and surname:'

# `.title()` makes first letter capital and rest lowercase
name = raw_input('Name: ').title()
surname = raw_input('Surname: ').title()

# use `.format(...)` to create fancy strings
print '{name} {surname}, the Great!'.format(name=name, surname=surname)

noes = ['no', 'n']
yesses = ['yes', 'y']

print '\nDid you like this?'

# `.lower()` for lowercase
if raw_input('Yes/No: ').lower() in noes:
    print '\nDo you really mean that?'
    if raw_input('Yes/No : ') in yesses:
        print '\nSo you\'ll be dead, {name}!'.format(name=name)
    else:
        print '\nOh, OK, then you\'re free to go, {name}.'.format(name=name)
else:
    print '\nThank you, {name}.'.format(name=name)
    print 'Try "no" next time!'

Here is another one:

#!/usr/bin/python

print 'Hi user, What\'s your name ?'

# `.title()` makes first letter capital and rest lowercase
name = raw_input('I\'m: ').title()

# `.format(...)` to create fancy strings
print ' Nice to meet you, {name}'.format(name=name)
print '\nI\'m Python'

noes = map(str, range(1, 18))

print 'How old are you, {name} ?'.format(name=name)
if raw_input('I\'m: ') in noes:
    print '\nI\'m Sorry, {name} your to young to talk with me'.format(name=name)
else:
    print 'Good, so your old enough to talk with me !'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s