You are on page 1of 4

PyTHON GASIC PROGRAMS

codin9_clves

This program prints Hello, worldL


print('Hello, world!)

ZThis program adds two numbers


numl =.S
num2 =. 3

+ Add two numbers


Sum Enuml t num2

+ Display the sum


print(Thesum of {0} and } is
12 tormat(numl, num2, Sum))

3. this Programto calculate the square root

num 8

Enuma floatlinput(Entera number: )

num sqt num* 0.5


print(Thesquare root of %0.3fis %.3f'%
(numnum-sqt}-
THON BASTC PROGRAMS

.Program to generate oa random number


between O and 9
importing the random module
import random

printlrandom.randint(0,9))
S. Kilometers to Miles
#taking kilome tersinputfrom the user
kilome ters floatlinput("Enter ralue in
kilome ters:"))

#conrersion toctor
conx fac 0.621371
calculoate miles
mileskilometers conx_tac
print(0.2fkilometers is equal to %0.2t
miles %l(kilometers,miles))--

Dowaloa.d as Pdfin Our Telegram Choannel


(inkin Gio) @coding-clues
TON 6ASTC PRoGRAMS
9-clues

l6.Convert Celsivs To Fahrenheit


# Python Program to converttemperature
incelsivs to fahrenheit
#change this value for a different result
celsivs = 31.5
# calculote fahrenheit
tahrenheitlcelsius 1.8) +32
print(%0.1fdegree Celsivsis equal to
%0.1f degree Fahrenheit
lcelsius,fahrenheiA))
1 Cheak Number Odd or Eren

num intlinput(Enter anumber: )


it(num %2) 0:
print("0} is Exen" format(num))
else:
-print("0} is 0dd" format(aum))

Dowaload as Pdf in Our Telegram Channel


(iak in Bio) @coding_clues
T O N ASTC PROGRAMS
coding-clvess

8.Display the multiplication Table


number aintlinput Enter the number: "))_
#
We are vsingfor loop

print (The Multiplication Toble of: "


number
torcount in rangel,1l):
print (number, x count, number covnt)

9.Find the Factors of a Number


def print_factorslx)
print(The factors of"x"are:")
for i in rangel, x + :
ifx %iaz 0:
print()

num 320

print tactors(num)

Downloadas Pdfin Our Teleqram Channel


(Linkin Gio) @coding-elues

You might also like