Posts

Showing posts from April, 2025

Python comments

  Python Comments # - This is comment symbol which is used for python. It means these lines will not execute as it is a comment. Example: # Going to print Hello World! print("Hello World!") Other ways to give a comments in python. # Multi line comment # second line # Third line. Same can be done by using  """ Any thing written under it will be considered as comments. check it by yourself. """ Assignment as example: Have $50 to purchase a thing and you have purchased an item of $15 and it has 3% tax on it. So now tell how much money is left with you? #Code """ Writing this code to solve the problem. Please find complet question below: Problem: Have $50 to purchase a thing and you have purchased an item of $15 and it has 3% tax on it. So now tell how much money is left with you? """ amount = 50 cost = 15 tax_rate = 0.03 tax = cost * tax_rate price = cost + tax remaining_amount = amount - price print (...

Python Variables

Python Variables   Variables: They are containers for holding data values. It will help you store the value in a memory location. example: cost = 10 print(cost) Now cost variable will direct you to get the information stored over the memory location which is holding the data 10. Variables help you to create formulas or help to reuse the data over different locations in a code. example: cost=10 tax_percent = 0.25 tax = cost * tax_percent price = cost I+ tax print(price) String datatype variable sample: username="Rock!rupesh" first_name="Rahul" print(username) print(first_name) print(username + " " + first_name) first_number=10 second_number=2 print(first_number) print(second_number) first_number=1 So you can modify the variable stored information according to your need. So as a summary variables are memory location which hold relevant information for your application.