# Connexions

You are here: Home » Content » Input (Umonya)

### Recently Viewed

This feature requires Javascript to be enabled.

# Input (Umonya)

Module by: Neil Muller. E-mail the author

## Input

Input is the process of getting information from the user. We want to know Bob's name or Sue's phone number and so on.

We use the command input to ask the user for information. input('Something ') will use the string 'Something' as a prompt to the user, and return everything the use types up until he or she hits Enter as a string.

A simple example

>>> input('What is your name? ')
'Bob'


Example 1

## Exercise 1

Ask Bob for his phone number

### Solution

input('What is your phone nymber? ')

Input returns a string. Sometimes we want to work with a number. We need to tell python that the input is a number, not a string. This is known as casting or type-casting

>>> float(input('Enter a number : ')) * 4
Enter a number : 2.5
10.0



Entering numbers

It's sometimes necessary to convert from numbers to strings. This is accomplished using str.

>>> 'The number is ' + str(1.5)
'The number is 1.5'

## Note:

"float" is short for 'floating point number', which is the usual name for numbers with a decimal place in computer programming. "str" is short for "string".

## Exercise 2

What happens if you don't convert to float? What does "input('Enter a number : ') * 4" give if you type "5"? Why?

'5555'

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks