Python- Introduction

Overview

  • Python was conceived in the late 1980s[33] by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to ABC programming language,
  • Python is an interpreted, high-level and general-purpose programming language.
  • Python 3.9.1 Latest Release Dec2020 https://www.python.org/downloads/

Tools Required

  • Python runtime : https://www.python.org/downloads/
  • Notepad++
  • IDE
    • VS Studio
    • Submlime
    • Pycharm
  • After Installation – Python run time files are copied to this location by default : C:\Users\\AppData\Local\Programs\Python\Python38-32
  • If Python is installed successfully, you should able to see the below in command prompt

HelloWorld Sample –Hello.py

#Sample Comment, Below command print's Hello World in the output.
print('Hello World')
#This is another comment line
print('addition of 2,3 is ' , 2+3 ,'multiplication of 3*15 is', 3*15)

#The print() function prints the specified message to the screen, or other standard output device.
#The message can be a string, or any other object, the object will be converted into a string before written to the screen.

How to get the current date and time in Python and Variable Declaration Sample

from datetime import date
from datetime import datetime
x=10
y='Smith'
z=100.5
print(y+'Salary is ' , x* z)
today = date.today()
print("Today's date:", today)
# datetime object containing current date and time
now = datetime.now() 
print("now =", now)
# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
print("date and time =", dt_string)

Comments |0|

Legend *) Required fields are marked
**) You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Category: Python