Python Basics Day 1 - Variables, Data Types, I/O, Operators, Basic Programs

I have started a python series to learn the knowledge of it. 𝐏𝐲𝐭𝐡𝐨𝐧 𝐃𝐒𝐀 𝐃𝐚𝐲 𝟏 - 𝐏𝐲𝐭𝐡𝐨𝐧 𝐁𝐚𝐬𝐢𝐜𝐬 𝐜𝐨𝐯𝐞𝐫𝐢𝐧𝐠. ✅ 𝐃𝐚𝐲 𝟏: 𝐏𝐲𝐭𝐡𝐨𝐧 𝐁𝐚𝐬𝐢𝐜𝐬 𝗧𝗼𝗽𝗶𝗰𝘀 𝗖𝗼𝘃𝗲𝗿𝗲𝗱: 1. Variables 2. Data Types 3. Input/Output (I/O) 4. Operators 5. Basic Programs:   * Calculator   * Swapping Numbers 1️⃣ 𝐕𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬 * Definition: A variable stores data that can change during program execution. * Syntax: x = 10 name = "Alice" * Python is dynamically typed, meaning you don’t need to declare the data type. 2️⃣ 𝗗𝗮𝘁𝗮 𝗧𝘆𝗽𝗲𝘀 Common data types in Python: int     10 float   10.5 str   "Hello" bool   True/False list   [1, 2, 3] tuple   (1, 2) dict   {"a": 1} 3️⃣ 𝗜𝗻𝗽𝘂𝘁 𝗮𝗻𝗱 𝗢𝘂𝘁𝗽𝘂𝘁 (𝗜/𝗢) * Input from user: name = input("Enter your name: ") * Convert input to int/float: age = int(input("Enter your age: ")) * Print Output: print("Hello,", name) 4️⃣ 𝗢𝗽𝗲𝗿𝗮𝘁𝗼𝗿𝘀 Arithmetic   + - * / % // ** Comparison   == != > < >= <= Logical     and or not Assignment   = += -= *= /= 5️⃣ 𝗕𝗮𝘀𝗶𝗰 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝘀 🔹 Calculator a = float(input("Enter first number: ")) b = float(input("Enter second number: ")) print("Sum =", a + b) print("Difference =", a - b) print("Product =", a * b) print("Quotient =", a / b) 🔹 Swap Numbers (with temp) x = 5 y = 10 temp = x x = y y = temp print("x =", x) print("y =", y) 🔹 Swap Numbers (without temp) x = 5 y = 10 x, y = y, x print("x =", x) print("y =", y) ✅ 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲 𝗧𝗶𝗽𝘀 * Use `input()` to take values and `print()` to display them. * Play around with different data types. * Try basic math programs on your own. ➣ 𝗦𝘂𝗴𝗴𝗲𝘀𝘁𝗶𝗼𝗻𝘀 𝗮𝗻𝗱 𝗖𝗼𝗿𝗿𝗲𝗰𝘁𝗶𝗼𝗻𝘀 𝗮𝗿𝗲 𝘄𝗲𝗹𝗰𝗼𝗺𝗲𝘀 ♻️ Share 👍🏻 React 💭 Comment ☑️ Repost ✴️ Follow Rishabh Bhat for more. Guided by Ratan Kumar jha #Python #Coding #Programming #DataScience #MachineLearning #AI #WebDevelopment #PythonProgramming #Automation #Tech #LearnPython #PythonForBeginners #SoftwareDevelopment #Developers #CodeNewbie #PythonProjects #TechEducation #Scripting #PythonCommunity

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories