Skip to content

bhaumikshukla/python-in-few-minutes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Learn python in few minutes (Tutorial)

learn-python.py this file contains all the code which are necessary to understand & to start with python. It has all the necessary definitions for variables, types, functions and many best practices to kick-start the basic programming with python.

You would need

  • Python 2.7
  • python-pip

requirements:

  • urllib2
  • requests

Make sure you install python-pip in linux machine, after installing python.

sudo apt-get install python-pip
pip install urllib2
pip install requests

Just go throught the learn-python.py file, read it thoroughly, learn from the source and try to execute it by following commands.

python learn-python.py

output will be appeared on console as follows:

Hello
World
Hello World
25
hi, how are you
Enter anything: anything
this is your input: anything
Enter a number: 10
<type 'int'> 10
<type 'str'> <type 'bool'> <type 'int'> <type 'float'> <type 'long'> <type 'NoneType'> <type 'dict'> <type 'list'>
Substring shorten one.
Substring shorten
Substring this
This is a dict value: John
This is a dict value: a
It's true
Yes, the value of x is < 50
it's 1
80 isn't available in l
for loop1 printing int: 1
for loop1 printing int: 2
for loop1 printing int: 3
for loop1 printing int: 4
for loop1 printing int: 5
for loop1 printing int: 6
for loop2 printing string: string1
for loop2 printing string: string2
for loop2 printing string: string3
1 <type 'int'>
2 <type 'int'>
string1 <type 'str'>
string2 <type 'str'>
False <type 'bool'>
1
3
5
7
9
11
13
15
17
19
Key:marks
Key:class
Key:name1
Key: marks Value: 87
Key: class Value: B
Key: name1 Value: John
Twocase called
[3, 6, 9]
[1, 2, 9, 4, 5, 36, 7, 8, 81]
printing after parsing json : innervalue
printing from default value: 140
printing from default value: 200
Server: nginx
Content-Type: text/html; charset=utf-8
X-Frame-Options: SAMEORIGIN
X-Clacks-Overhead: GNU Terry Pratchett
Content-Length: 48170
Accept-Ranges: bytes
Date: Wed, 09 Aug 2017 09:48:53 GMT
Via: 1.1 varnish
Age: 3363
Connection: close
X-Served-By: cache-lcy1142-LCY
X-Cache: HIT
X-Cache-Hits: 2
X-Timer: S1502272134.730889,VS0,VE0
Vary: Cookie
Strict-Transport-Security: max-age=63072000; includeSubDomains

/home/bhaumik/envtest/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/home/bhaumik/envtest/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/home/bhaumik/envtest/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
200
Reading from file:  This is a sample string which will be written in file.
Please enter a number, I'm learning try_catch: 10
Thank you, I received a number
Number worked fine.