Loading...
More Python Posts
bytes_data = b'Hello, World!'string_data = bytes_data.decode('utf-8')print("String:", string_data)
# Python code to demonstrate# method to remove i'th character# Naive Method# Initializing Stringtest_str = "CodeCatch"# Printing original stringprint ("The original string is : " + test_str)# Removing char at pos 3# using loopnew_str = ""for i in range(len(test_str)):if i != 2:new_str = new_str + test_str[i]# Printing string after removalprint ("The string after removal of i'th character : " + new_str)
def byte_size(s):return len(s.encode('utf-8'))byte_size('😀') # 4byte_size('Hello World') # 11
x[cat_var].isnull().sum().sort_values(ascending=False)
# Python Program to calculate the square rootnum = float(input('Enter a number: '))num_sqrt = num ** 0.5print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))
import random# Define the ranks, suits, and create a deckranks = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King']suits = ['Hearts', 'Diamonds', 'Clubs', 'Spades']deck = [(rank, suit) for rank in ranks for suit in suits]# Shuffle the deckrandom.shuffle(deck)# Display the shuffled deckfor card in deck:print(card[0], "of", card[1])