
Python is a great language for beginners because it's easy to read and write. You can use it for many things like making websites, analyzing data, or even creating smart programs. Python comes with lots of ready-to-use tools and doesn't need complicated code. It can do different types of programming, so you can choose what fits best for your project. Overall, it's a friendly language that's perfect for starting your coding journey!
| # Integer variable my_integer = 10 # String variable my_string = "Hello, there!" # Boolean variable is_true = True # List variable my_list = [1, 2, 3, 4, 5] # Float variable my_float = 3.14 # Printing the variables print("Integer:", my_integer) print("String:", my_string) print("Boolean:", is_true) print("List:", my_list) print("Float:", my_float) |
| x = 5 if x > 0: print(“x is positive”) else: print(“x is negative”) |
| # Example of a for loop fruits = ["apple", "banana", "Cherry"] for fruit in fruits: print(fruit) |
| #output apple banana Cherry |
| # Example of a while loop count = 0 while count < 5: print(count) count += 1 In this code, while loop will start running from 0 and will run until the value of “Count” remains less than 5, whenever value matches equal to or more than 5 then the loop will exit. |
| #output 0 1 2 3 4 |
| S.No. | Libraries | Thier Uses |
| 1 | NumPy | For numerical computing and array operations. |
| 2 | Pandas | For data manipulation and analysis with data structures like DataFrames. |
| 3 | SciPy | For scientific computing, optimization, and statistics. |
| 4 | Matplotlib | For data visualization, plotting graphs, and charts. |
| 5 | Scikit- Learn | For machine learning algorithms, data preprocessing, and model evaluation. |
| 6 | TensorFlow | An open-source machine learning platform developed by Google. |
| 7 | PyTorch | A deep learning framework with dynamic computation graphs. |
| 8 | Beautiful Soup | For web scraping and parsing HTML/XML documents. |
| 9 | OpenCV | For computer vision tasks like image processing and object detection. |
| # Define a class named Person class Person: # Constructor method to initialize attributes def __init__(self, name, age): self.name = name self.age = age # Method to greet the person def greet(self): print("Hello, my name is", self.name, "and I am", self.age, "years old.") # Create an object of the Person class person1 = Person("Sahil", 21) # Access object attributes and call object methods print("Person's name:", person1.name) print("Person's age:", person1.age) person1.greet() # Call the greet method |
| #Output Person's name: Sahil Person's age: 21 Hello, my name is Sahil and I am 21 years old. |