Posts Tagged with 'Python'

String manipulation is an essential skill in Python programming, and today, we’ll explore a fun and creative problem! ✅ Problem Statement: Given two strings, we will: Swap the first two characters of each string. Combine …

Last updated 1 month, 1 week ago | 68 views

Tags:- Python

String manipulation is a fundamental concept in programming, and today, we’ll explore an interesting problem: ✅ Given a string, replace all occurrences of its first character with '$', except for the first occurrence. This simple …

Last updated 1 month, 1 week ago | 47 views

Tags:- Python

When working with strings in Python, there are times when you need to extract specific parts of a given string. In this tutorial, we will write a simple Python program that extracts the first two …

Last updated 1 month, 1 week ago | 53 views

Tags:- Python

You can determine the frequency of each character in a string using Python's collections.Counter or a simple dictionary. Method 1: Using collections.Counter (Efficient) from collections import Counter text = "hello world" print(dict(Counter(text))) #Output: {'h': 1, …

Last updated 1 month, 2 weeks ago | 90 views

Tags:- Python

In Python, you can count the length of a string using the len() function. text = "Hello, World!" length = len(text) print("Length of the string:", length) # Output: Length of the string: 38 The len() …

Last updated 1 month, 2 weeks ago | 59 views

Tags:- Python

To ensure your Django sitemap uses HTTPS, you can specify the protocol by adding it as a class variable in your sitemap class. Solution: Define Protocol in Sitemap Class Django's sitemap framework uses 'http' as …

Last updated 1 month, 2 weeks ago | 72 views

Tags:- Python Django Django Sitemap Framework

Python | Check the memory usage of  an object >>> import sys >>> x = 100 >>> print(sys.getsizeof(x)) 28  

Last updated 2 years, 7 months ago | 1107 views

Tags:- Python

Python | Print String N times >>> s = 'Python' >>> n = 5 >>> print(s * n) PythonPythonPythonPythonPython  

Last updated 2 years, 7 months ago | 993 views

Tags:- Python Django

Python | Return multiple values from functions >>> def A(): return 2, 3, 4 >>> a, b, c = A() >>> print(a, b, c) 2 3 4  

Last updated 2 years, 7 months ago | 892 views

Tags:- Python Django

Python | Join all items of a list to convert into a single string >>> x = ["Python", "Online", "Training"] >>> print(" ".join(x)) Python Online Training  

Last updated 2 years, 7 months ago | 868 views

Tags:- Python Django

Python | Reversing a String >>> x = 'PythonWorld' >>> print(x[: : -1]) dlroWnohtyP  

Last updated 2 years, 7 months ago | 908 views

Tags:- Python Django

 Python | In-place swapping of two numbers >>> a, b = 10, 20 >>> print(a, b) 10 20 >>> a, b = b, a >>> print(a, b) 20 10  

Last updated 2 years, 7 months ago | 914 views

Tags:- Python Django

A few common security issues that can be avoided by using Django are: Clickjacking Cross-site scripting and SQL injection

Last updated 2 years, 8 months ago | 1137 views

Tags:- Python

Difference between Python array and Python list Array Lists it is used to store only homogeneous data. The list is used to store heterogeneous data it occupies less amount of memory as the array stores …

Last updated 2 years, 8 months ago | 1011 views

Tags:- Python

Python program to count the number of capital letters in a file. with open(FILE_NAME) as my_file: count = 0 text = my_file.read() for character in text: if character.isupper(): count += 1 print(count)    

Last updated 2 years, 8 months ago | 1056 views

Tags:- Python