Posts

Tkinter in Python

Tkinter in Python  If you want to create GUI (Graphical User Interface) applications in Python, Tkinter is the most popular and beginner-friendly library. It is built into Python, so you don't need to install anything separately. This article explains Tkinter with examples, widgets, layout managers, aand inbuilt functions, making it perfect for students, beginners, and exam aspirants.  What is Tkinter? TKinter is Python's standard GUI package used to create desktop applications. It provides windows, buttons, labels, text fields, dialogues, menus, and more. Tkinter is: Built-in (comes with Python) Easy to use Cross-platform Used to create apps like ✔ Calculator ✔ Notepad ✔ Form applications ✔ Games  Creating Your First Tkinter Window Example 1: Basic Window import tkinter as tk root = tk.Tk() root.title("My First Tkinter App") root.geometry("300x200") root.mainloop() Explanation Tk() → creates main window title() → set...

Set quiz

  MCQ Quiz on Set Data Type in Python Which of the following creates an empty set? {} [] set() empty() Which feature of a set is correct? Ordered collection Unordered unique elements Allows duplicates Supports indexing What will be the output of {1, 2, 2, 3}? {1,2,2,3} {1,2,3} {2,3} Error Which method is used to add an element to a set? add() append() insert() push() Which method removes an element without raising an error? remove() discard() pop() delete() Which operator performs union? & - | ^ Which is NOT a valid set method? update() intersection() difference() slice() What is the output of {1, 2, 3} & {2, 3, 4}? {1,4} {2,3} {1,2,3,4} {3,4} Which operator is used for symmetric difference? | & ^ % What will {1,2,3} - {2,3} return? {1} {2} {3} {1,2,3} Which method clears a set? removeAll() clear() delete() empty() The pop() method remov...

Topic 15: Set in python?

Image
Set Data Type in Python Python provides several built-in data types, and Set is one of the most powerful and useful among them. A set is an unordered collection of unique elements, commonly used for operations like removing duplicates, mathematical set operations, and fast membership testing. You will learn: ✔ What a set is ✔ How to create sets in Python ✔ Important operations on sets ✔ Built-in functions and methods ✔ Practical examples  What is a set in Python? A set in Python is a collection of unordered, unindexed, and unique elements. It is defined using curly braces { } or the set() constructor . Example my_set = {1, 2, 3, 4} print(my_set) # {1, 2, 3, 4} mixed_set = {10, "Python", 3.14} print(mixed_set) # Elements in random order  Key Characteristics of Sets Feature Description Unordered Elements have no fixed position Unique elements Duplicate values are automatically removed Mutable You can add or remove elements No inde...

Preprocessing in Machine Learning?

Image
Machine learning models are only as good as the data they are trained on. Before feeding data into a model, it must be cleaned, transformed, and prepared  a process known as "data preprocessing."  Let’s explore what preprocessing is, why it’s important, and how it’s done with a practical example. What is data preprocessing? Data preprocessing is the process of converting raw data into a clean and usable format for machine learning algorithms. It involves handling missing values, scaling features, encoding categorical variables, and splitting data into training and testing sets. In simple words, preprocessing makes sure that your data is in the right shape and scale for your model to understand. Why is preprocessing important? Without proper preprocessing: Models may produce inaccurate results . Algorithms can become biased due to inconsistent data. Features with large ranges can dominate the training process. Missing or invalid data may cause errors ...

Dictionary Quiz

  Python Dictionary Quiz 🧠 Python Dictionary Data Type – Quiz 1. What is a dictionary in Python? A collection of ordered items A collection of key-value pairs A collection of unique values only 2. Which symbol is used to create a dictionary? [ ] { } ( ) 3. Keys in a Python dictionary must be: Mutable Immutable Duplicated 4. How to access value of key “name” from dictionary d? d.name d[name] d["name"] 5. Which method removes a specific key from a dictionary? remove() discard() pop() 6. Which method returns all keys of a dictionary? get() keys() values() 7. What is the output of len({"a":1, "b":2, "c":3}) ? 3 6 Error 8. Which method is used to co...

Topic 14: Dictionary Data Type in Python

Image
In Python, a dictionary is one of the most powerful and flexible data types. It allows you to store data in key–value pairs , just like a real-world dictionary where words (keys) have meanings (values). Dictionaries are unordered, mutable , and indexed by unique keys , making them ideal for quick lookups and data organization. Syntax of Dictionary # Creating a dictionary my_dict = { "name": "Alice", "age": 25, "city": "Delhi" } Keys : Must be unique and immutable (e.g., strings, numbers, tuples). Values : Can be of any data type (string, list, number, etc.). Creating a Dictionary 1️⃣ Using Curly Braces {} student = {"name": "John", "roll_no": 101, "course": "B.Tech"} 2️⃣ Using dict() Constructor student = dict(name="John", roll_no=101, course="B.Tech") Accessing Dictionary Elements You can access values using their key names . stud...

Tuple Quiz

  Tuple in Python - MCQ Quiz 🟣 Tuple in Python — MCQ Quiz (15) Select one answer per question. Click Submit to see your score. 1. Which Python data type is immutable ? a) list b) tuple c) set d) dict 2. How do you create a single-element tuple containing the string "a"? a) ("a") b) ("a",) c) ["a"] d) (a,) 3. How do you access the first element of a tuple t ? a) t[0] b) t(0) c) t.first() d) t.get(0) 4. Which built-in function converts a list [1,2,3] into a tuple? a) convert() b) to_tuple() c) tuple() d) list() 5. Which operator concatenates two tuples (1,2) and (3,4) ? a) * b) + c) & d) .concat() 6. Which tuple method returns the number of occurrences of a value? a) index() b) find() c) count() d) occurrences() 7. Which of the following ...