# Write the python program to generate a random number between 0 and 9 - Python

Categories:
Viewed: 4 - Published at: a few seconds ago

### Write the python program to generate a random number between 0 and 9

``````import csv
with open(input_file) as csv_file:
print(f'{row}')
break
``````

### Write a python program to Generate a Random Number

``````import random
print(random.randint(0,9))
``````

### Write a python program to Check Leap Year

``````year = 2000
if (year % 4) == 0:
if (year % 100) == 0:
if (year % 400) == 0:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
else:
print(f"{year} is a leap year")
else:
print(f"{year} is not a leap year")
``````

### Write a python function to Compute LCM

``````def compute_lcm(x, y):
if x > y:
greater = x
else:
greater = y

while(True):
if((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1

return lcm
``````

### Write a python function to compute gcd

``````def compute_gcd(x, y):

while(y):
x, y = y, x % y
return x
``````

### Write a python program to Remove Punctuations From a String

``````punctuations = '''!()-[]{};:'"\,<>./?@#\$%^&*_~'''
my_str = "Hello!!!, he said ---and went."
no_punct = ""
for char in my_str:
if char not in punctuations:
no_punct = no_punct + char
print(no_punct)
``````

### Write a python function to Find Hash of File

``````import hashlib
def hash_file(filename):

h = hashlib.sha1()
with open(filename,'rb') as file:
chunk = 0
while chunk != b'':
h.update(chunk)
return h.hexdigest()
``````

### Write a python Program to Find the Size (Resolution) of a JPEG Image and print it

``````def jpeg_res(filename):
with open(filename,'rb') as img_file:
img_file.seek(163)

# calculate height
height = (a << 8) + a

# next 2 bytes is width

# calculate width
width = (a << 8) + a

print("The resolution of the image is",width,"x",height)
``````

### Write a python program to count the number of each vowels

``````ip_str = 'Hello, have you tried our tutorial section yet?'
ip_str = ip_str.casefold()
count = {x:sum([1 for char in ip_str if char == x]) for x in 'aeiou'}
print(count)
``````

### Write a python Program to Find ASCII Value of Character

``````c = 'p'
print("The ASCII value of '" + c + "' is", ord(c))
``````

### Write a python Program to Solve Quadratic Equation

``````import cmath
a = 1
b = 5
c = 6
d = (b**2) - (4*a*c)
sol1 = (-b-cmath.sqrt(d))/(2*a)
sol2 = (-b+cmath.sqrt(d))/(2*a)
print('The solution are {0} and {1}'.format(sol1,sol2))
``````

### Write a python program to Convert Celsius To Fahrenheit

``````celsius = 37.5
fahrenheit = (celsius * 1.8) + 32
print(f'{celsius} degree Celsius is equal to {fahrenheit} degree Fahrenheit')
``````

### Write a python program to check Armstrong number of n digits

``````num = 1634
order = len(str(num))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10
if num == sum:
print(num,"is an Armstrong number")
else:
print(num,"is not an Armstrong number")
``````