December 3, 2017

Getting Started with Python on Ubuntu 16.04

Prerequisite

Ubuntu 16.04

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

Interactive Mode

$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1
2

IDE - IDLE

$ sudo apt-get install idle
$ idle
File -> New File 
File -> Save as... -> hello.py
#!/usr/bin/env python3

name = input("Name: ")
print ("Hello " + name)

Reference

The Python Tutorial - https://docs.python.org/3/tutorial/

No comments: