Posts

Showing posts from June, 2021

Python KeyWords

Keywords are predefined words with special meaning to the language compiler or interpreter. These are reserved for special purposes and must not be used as normal identifier names. Serial No Keyword Description Example 1 False instance of class bool. x = False 2 class keyword to define a class. class Foo: pass 3 from clause to import class from module from collections import OrderedDict 4 or Boolean operator x = True or False 5 None instance of NoneType object x = None 6 continue continue statement, used in the nested for and while loop. It continues with the next cycle of the nearest enclosing loop. numbers = range(1,11) for number in numbers: if number == 7: continue 7 global global statement allows us to modify the variables outside the current scope. x = 0 def add(): global x x = x + 10 add() print(x) # 10 8 pass Python pass statement is used to do nothing. It is useful when we require some statement but we don’t want to execute any code. def foo(): pass 9 True instance of bool cla...

Python Variables

Image
  Variables: Variables are containers which hold different type of data. We can call or use that data by referencing the variable name. Creating Variable: Python has no method or declaration for creating a variable. you can create a variable  in python like below x= 5 name= "avyukta" list = [ 1 , 2 , 3 , 4 ] you can create a variable  in python like below Rules to be taken care of when creating python variable: A variable name must start with a letter or the underscore character. A variable name cannot start with a number. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) Variable names are case-sensitive (age, Age and AGE are three different variables)

Python Comments

Image
Introduction Comments in a python program is a collection of characters that are ignored by the interpreter. comments in programs make code more readable for humans as it provides some information or explanation about what each part of a program is doing. Comments can also serve as notes or reminders to yourself, or they can be written with the intention that other programmers can understand your code or what you are doing. In general, it is a good idea to write comments while you are writing or updating a program as it is easy to forget your thought process later on. Comment Syntax: Comments in Python begin with a hash mark (#) . Generally, comments will look something like this: # This is a comment   Copy Because comments do not execute, It will not affect your code execution. Comments are intended for humans to read. They are not executed by the interpreter. In a “Hello, World!” program, a comment may look like this: hellow_world.py # Print “Hello, World!” to console print ( "...