Posts

Theory on CSV Files

  # Introduction   A CSV (Comma Separated Values) file is a simple type of text file used to store data in a table format. It's commonly used for exchanging data because it's easy to read and create. Each line in a CSV file represents a row in the table, and commas are used to separate the values in each column. CSV files have .csv as file extension.    Let us take a CSV file named data.csv which has the following contents:  Roll No., Name of student, stream, Marks  1, Panda, Science, 426  2, Piyush, Science, 445    As you can see each row is a new line, and each column is separated with a comma. This is an example of how a CSV file looks like.     To work with csv files, we have to import the csv module in our program.    # Read a CSV file:  To read data from a CSV file, we have to use reader( ) function.  The reader function takes each row of the file and make a list of all columns.   ...

Python Practicals

  # Printing Hello World print ( "Hello World." ) # Write a program to display ASCII code of a character and vice versa. Theory : The ASCII (American Standard Code for Information Interchange) code of a character is a numerical representation of a character such as a letter, number, or symbol. Each character has a unique ASCII code. Here are a few examples of ASCII codes: The ASCII code for the letter "A" is 65. The ASCII code for the digit "0" is 48. The ASCII code for the exclamation mark "!" is 33 . Code : var = True while var :   choice= int (input( "Press-1 to find the ordinal value of a character.\nPress-2 to find the character of a value.\nEnter you choice : " ))    if choice== 1 :     ch=input( "Enter the character :" )     o=ord(ch)      print ( "The ordinal value of " ,ch, "is" ,o)   elif choice== 2 :     val= int (input( "Enter the ordinal value : " )) ...