Skip to main content

Posts

Variables & Type of Literals and Operators

Recent posts

Programming Questions

Programming Questions with source code Program 1: Program to obtain side of a square and then calculate its area.   Input code:  a=int(input("Enter the side of square:")) sq=a**2 print("Area of square is :",sq) Program 2: Program to obtain length and breadth of a rectangle and calculate its area. Input Code:   l=int(input("Enter length of the rectangle:")) b=int(input ("Enter breadth of the rectangle:")) area=l*b print("Area of rectangle is:",area) Program 3: Program to obtain height and base of a triangle and calculate its area.   Input Code: l=int(input("Enter length of triangle")) b=int(input("Enter base of triangle")) area=0.5*b*h print("Area of triangle is:",area) Program 4: Program to obtain a number and print its square and cube. Input Code:   num=float(input("Enter the number:")) sq=num*num cube=num*num*num print("Square of",num,"is",sq) print("Cube of",num,&q

Python's Token

Tokens are the smallest individual unit in a program. It's also called lexical unit. Types of token Identifiers Keywords Operators Literals Punctuators Identifiers Identifier are used as a name to identify variables, list, dictionaries, classes, objects, variables, functions, etc. Some rules of making identifier: • It can be of any length. • The first character should be a letter or underscore ( _ ). • Keywords cannot be used as an identifier. • Digits can be used except in the first character of an identifier. • No special characters should be used except underscore ( _ ). For example: _hello _Hello Python1 Keywords Keywords are reserved words in a programming language which has a special meaning. Operators Operators are the characters that triggers some computation when applied to variables. There are various types of operators in Python: Arithmetic Operators Relational Operators Membership Operators Bitwise Operators Identity Operators Logical Operators Assignment Oper

Introduction to Python

Python is a high level, object oriented programming language. It has simple and easy to learn syntax. It is good for beginners as well as for developers. Python is used in various fields now with its growth in popularity as compared to other Programming languages like Java, C, PHP, etc. Python was developed by Guido Van Rossum in February 1991 . Python was supposed to be a successor of the ABC language. Python programming language was named after the famous BBC Comedy show, Monty Python's Flying Circus.