Lesson 3:

Writing Our First Program

This is a simple program that says Hello and asks for my name.

Hello 'name' program:


In [ ]:
print('Hello World')
print('Whats is your name?') # ask for their name
myName = input()
print('It is good to meet you, ' + myName)
print('The length of your name is:')
print(len(myName))
print('Whats is your age?') # ask for their age
myAge = input()
print('You will be ' + str(int(myAge) +1) + ' in a year.')


Hello World
Whats is your name?

Recap:

  • Type programs into the file editor
  • The execution starts the top and moves down
  • '#' Comments are ignored by Python
  • Functions are mini-programs iny our program
  • 'print()' displays the value passed into it
  • 'intput()' lets user type in a value
  • 'len()' takes a string value and returns an integer value of the string's length
  • 'int()', 'str()', and 'float()' convert value's data type