Posts

Tkinter and Api

Image
Document Home HG Blogs Tkinter and Api In this blog, we'll walk through the basics of Tkinter, how to interact with APIs. Whether you're a beginner or looking to brush up on your programming skills, this guide will set you on the right path to mastering Python and Tkinter. Tkinter Tkinter is like a special set of tools that helps you build that program. It gives you the building blocks – like buttons, boxes, and labels – and lets you put them together to create a program that looks nice and is easy to use. Widgets of Tkinter Label This is used to display text or images. For instance, you can use Label to show the current temperature, weather conditions, or the name of the city. from tkinter import Label lab...

Recursion In Python

Image
Document Home HG Blogs Recursion Recursion involves a function calling itself directly or indirectly to solve a problem by breaking it down into simpler and more manageable parts. Python Recursive Function In Python, a recursive function is defined like any other function, but it includes a call to itself. def factorial(n): if n == 1: return 1 else: return n * factorial(n-1) print(factorial(5)) Basic Structure of Recursive Fucntion def recursive_function(parameters): if base_case_condition: return base_result else: return recursive_function(modified_parameters) ...

Functions in Python

Image
Document Home HG Blogs Functions The functions in python can be defined as the reusable block of codes that perform a certain task. Before we start defining functions ourselves, we’ll look at some of Python’s built-in functions. Let’s start with the most well-known built-in function, called print: >>> print('Hello, readers!') Hello, readers! >>> print(15) 15 Creating python functions In programming language there are certain syntax we need to follow and python is not an exception def function_name: #statements return Advantages of using functions Advantages of using functions A Python function can be defined once and used many times. So it aids in code reuse: you ...

Sets in python

Image
Document Home HG Blogs SETS Sets are an ideal choice for representing a group of unique values as a single entity. They offer several key characteristics: they do not allow duplicate elements, they do not preserve the order of insertion, and they do not support indexing or slicing. While the order of elements may not be guaranteed, sets can be sorted for specific purposes. This makes sets useful for tasks like removing duplicates from a list or performing set operations like union, intersection, and difference. s={10,20,30,40} print(s) Ouput:{10,20,30,40} Important set functions add(x): When we want to add individual element to the set we use add() ex...

List and Tuple in Python

Image
Document Home HG Blogs List A list is a data type in Python used to store a collection of items. Lists are mutable, which means we can modify their contents after they are created.The data in the list is stored in the square brackets. lst = [1,2,3,4,5] Accessing the elements of the list The elemnts of the list can be accessed by two methods By Indexing By Slice Operator Indexing lst = [1,2,3,4] print(lst.[0]) output:1 Slice operator list = list1[start:stop:step] start ==>it indicates the index where slice has to sta...

Strings and String Operations In Python

Image
Document Home HG Blogs Strings The string is defined as any set of characters within either single quote or the double quotes. ex: s='Notes' s="Notes" HOW TO ACESS CHARCTERS OF THE STRING There are two ways to access the characters in the string By Indexing By Slice Operator Indexing s = "Notes" print(s[0]) Output:N print(s[1]) Output:o print(s[2]) Output:t print(s[3]) Output:e print(s[4]) Output:s Slice Operators Syntax: s[begin:end:step] Begin: From where the we have to consider the slicing of the string End: From where the slicing of the string will ...

For Loop and While Loop in Python

Image
Document Home HG Blogs For Loop A for loop is a control flow statement that allows you to execute a block of code repeatedly for a specified number of times. It's particularly useful when you know in advance how many times you want the loop to iterate. Example: for i in range(6): print(i) While Loop A while loop is another control flow statement that executes a block of code repeatedly as long as a certain condition is true. It's useful when you don't know the exact number of iterations in advance. Example: i=0 while i Follow on LinkedIn