Skip to main content

collect dictionary

0 likes • Nov 19, 2022
Python
Loading...
Download

More Python Posts

Finding NULL values within set

KETRICK
0 likes • Oct 7, 2022
Python
x[cat_var].isnull().sum().sort_values(ascending=False)

Color Gradient

Skrome
0 likes • Mar 10, 2021
Python
color2 = (60, 74, 172)
color1 = (19, 28, 87)
percent = 1.0
for i in range(101):
resultRed = round(color1[0] + percent * (color2[0] - color1[0]))
resultGreen = round(color1[1] + percent * (color2[1] - color1[1]))
resultBlue = round(color1[2] + percent * (color2[2] - color1[2]))
print((resultRed, resultGreen, resultBlue))
percent -= 0.01

key of minimum value

CodeCatch
0 likes • Nov 19, 2022
Python
def key_of_min(d):
return min(d, key = d.get)
key_of_min({'a':4, 'b':0, 'c':13}) # b

Input 2D Matrix

CodeCatch
0 likes • Nov 19, 2022
Python
# Input for row and column
R = int(input())
C = int(input())
# Using list comprehension for input
matrix = [[int(input()) for x in range (C)] for y in range(R)]

Calculate Square Root

AustinLeath
0 likes • Nov 18, 2022
Python
# Python Program to calculate the square root
num = float(input('Enter a number: '))
num_sqrt = num ** 0.5
print('The square root of %0.3f is %0.3f'%(num ,num_sqrt))

Remove i'th character

CodeCatch
0 likes • Nov 19, 2022
Python
# Python code to demonstrate
# method to remove i'th character
# Naive Method
# Initializing String
test_str = "CodeCatch"
# Printing original string
print ("The original string is : " + test_str)
# Removing char at pos 3
# using loop
new_str = ""
for i in range(len(test_str)):
if i != 2:
new_str = new_str + test_str[i]
# Printing string after removal
print ("The string after removal of i'th character : " + new_str)