Posts

Python File IO Basics

  r : r mode opens a file for read-only. We do not have permission to update or change any data in this mode. w : w mode does not concern itself with what is present in the file. It just opens a file for writing and if there is already some data present in the file, it overwrites it. x : x is used to create a new file. It does not work for an already existing file, as in such cases the operation fails. a : a stands for append, which means to add something to the end of the file. It does exactly the same. It just adds the data we like in write(w) mode but instead of overwriting it just adds it to the end of the file. It also does not have the permission of reading the file. t : t mode is used to open our file in text mode and only proper text files can be opened by it. It deals with the file data as a string. b : b stands for binary and this mode can only open the binary files, that are read in bytes. The binary files include images, documents, or all other files that require specific s

Break & Continue Statements In Python

  i =  0 while  ( True ):      if  i+ 1 < 5 :         i = i +  1          continue      print (i+ 1 ,  end = " " )      if (i== 50 ):          break       i = i +  1 Exercise:: while ( True ):     inp =  int ( input ( "enter your number" ))      if  inp> 100 :          print ( "congrats you have entered a number greater than 100" )          break      else :          print ( "try again!" )          continue

Calculator

print ( "enter your first number" ) num1 =  int ( input ()) print ( "enter your second number" ) num2 =  int ( input ()) print ( "the product of num1 and num2" ,num1*num2) operator =  input ( "Enter operator:" ) val1 =  int ( input ( "Enter first number = " )) val2 =  int ( input ( "Enter second number = " )) print  ( int ( "sum of val1 and val2" ))

Dictionary function basic code

d4 = { "Adnan" : "15.4.2020" ,   "Amroz" : "14.4.2020" ,   "Amjad" : "31.12.2000" } name = input ( "enter the name :" ) print (d4[name]) if you enter this keys you give data

What is your Age Drive Coding

print ( "what is your age" ) age =  int ( input ()) if  age< 18 :      print ( "you connot drive" ) elif  age== 18 :      print ( "we think about you" ) else :      print ( "you can drive" ) Visit This Link For Great Information:   Our Weeks