Write a Python Program to Convert Kilometers to Miles
kilometers = 10.0
conv_fac = 0.621371
miles = kilometers * conv_fac
print('%0.2f kilometers is equal to %0.2f miles' %(kilometers,miles))
write a Python Program to Convert Celsius To Fahrenheit
celsius = 37.5
fahrenheit = (celsius * 1.8) + 32
print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit))
write a Python Program to Check if a Number is Positive, Negative or 0
num = 10
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Python Program to Check if a Number is Odd or Even
num = 100
if (num % 2) == 0:
print("{0} is Even".format(num))
else:
print("{0} is Odd".format(num))
Python Program to Display the multiplication Table
num = 12
for i in range(1, 11):
print(num, 'x', i, '=', num*i)
write a program for Rolling the dices
import random
min = 1
max = 6
print("Rolling the dices...and the values are",random.randint(min, max))
print("Rolling the dices...and the values are",random.randint(min, max))
write a python program to calculate the average
list1 = [1,3,4,5]
average = (sum(list1)) / len(list1)
print(f"the average score is: {average} ")
write a python program to print reverse list
print(f'reverese the given list elements:{list1[::-1]}')
write a python program for creating the thread
import threading
from threading import Thread
import time
def print_time( threadName, delay):
count = 0
while count < 5:
time.sleep(delay)
count += 1
print("%s: %s" % ( threadName, time.ctime(time.time()) ))
# try:
# Thread(target=print_time, args=("Thread-1", 2, )).start()
# Thread(target=print_time, args=("Thread-1", 4, )).start()
# except:
# print("Error: unable to start thread")
# write a python program to check a num is less than 1000
def near_thousand(n):
return ((abs(1000 - n) <= 100) or (abs(2000 - n) <= 100))
print('near to 1000',near_thousand(1000))
print('near to 1300',near_thousand(1300))