Python Short Notes

Python Short Notes

Basic Syntax

  • identation (4 spaces)
  • for comments use # comment
  • for multiline comment use

''' comment '''

  • for Output in console : print()

variables

  • container to store data
  • starts with letters and underscore _
  • to assign varible use = operator

eg: x=5

  • to assign multiple variables in single line

eg: a,b,c=1,2,3

Data Types

  • Integer int(3)

  • Float float(3.12)

  • complex complex(3,2)

  • List : [1,2,3]

  • Dictionary :

  • Set : set()

  • tuple : ()

  • frojen set : ()

Conditional statements

if elif else

  • Conditional statements allow you to execute certain parts of your code based on specific conditions.
if condition:
    # code block to execute if condition is true
elif another_condition:
    # code block to execute if another_condition is true
else:
    # code block to execute if all conditions are false

for loop

A for loop is used for iterating over a sequence (such as a list, tuple, dictionary, set, or string).

for i in range(5):
    print(i)

while loop

A while loop is used to repeat a block of code as long as a condition is true.

count = 0

while count < 5:
    print(count)
    count += 1
Team
Team

This account on Doubtly.in is managed by the core team of Doubtly.

Articles: 483

jsDelivr CDN plugin by Nextgenthemes

These are the assets loaded from jsDelivr CDN. Do not worry about old WP versions in the URLs, this is simply because the files were not modified. A sha384 hash check is used so you can be 100% sure the files loaded from jsDelivr are the exact same files that would be served from your server.


	

Level up your video embeds with ARVE or ARVE Pro