Skip to content

Commit 2de4b97

Browse files
Add files via upload
1 parent 79cc26d commit 2de4b97

18 files changed

+170
-0
lines changed

average.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# program to find an average of N numbers .
2+
3+
n=5
4+
sum=0
5+
count=0
6+
while count<n:
7+
number=float(input(" "))
8+
sum=sum +number
9+
count=count+1
10+
average = float(sum)/n
11+
print("n = %d , sum = %f" %(n ,sum))
12+
print("Average = %f" % (average))

comment.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#this is a comment
2+
# the next line will be written
3+
# comments are added to understand the code easily
4+
# the can not execute into the code
5+
a=12+34
6+
print(a)

devmod.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# divmod(num1 , num2 )
2+
# this function return two values
3+
4+
# taking input as days
5+
days = int (input("enter days "))
6+
7+
# first is the division of num1 and num2
8+
# second is the modulo of num1 and num2
9+
print("Months = %d Days =%d " % (divmod(days,30)))

evalueateequ.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# program to evaluate 1/x+1/(x+1)+1/(x+2)+ ... +1/n series upto n,
2+
# in our case x = 1 and n =10
3+
4+
sum = 0.0
5+
for i in range (1,11):
6+
sum += 1.0 / i # actually happening is sum = sum + 1.0 / i
7+
print ("%2d %6.4f" % (i , sum ))

fibo.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# program for Fibonacci Series .
2+
# series looks like 1,1,2,3,5,8,13 .......
3+
a = 0
4+
b =1
5+
while b<100:
6+
print(b)
7+
a,b = b , a+b

hello.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# basic program to print hello world in python
2+
# INPUT
3+
print("hello")
4+
print("hello \n \t world.n]")
5+
# \n means print in next line
6+
# \t means long space
7+
8+

if.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# program to check a number is less than 100 or not .
2+
# taking n a in - put
3+
n = int(input("enter number :"))
4+
# applying condition using if
5+
6+
# if is use for true condition
7+
if n<100:
8+
print("no. is less than 100")
9+
10+
# else is works when if statement is not fulfilled.
11+
else :
12+
print("no. is greater than 100")

invest.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# program to calculate investments .
2+
# taking input amount , rate , period .
3+
amount=float (input("enter amount"))
4+
rate=float(input("enter rate "))
5+
period=int(input("enter year "))
6+
7+
# initialization of value , year
8+
value=0
9+
year=1
10+
11+
# gave condition in while loop
12+
while year<=period:
13+
value= amount +(rate * amount)
14+
print(year,value)
15+
16+
# update
17+
amount=value
18+
year = year +1

modul.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import math
2+
print(math.e)

operator.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# operators
2+
print(2+3) # addition
3+
print(45-3) # subtraction
4+
print(22/11) # division
5+
print( 3* 34) # multiplication

quad.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# program to evaluate the roots of quadratic equation .
2+
3+
import math
4+
a = int(input("enter a :"))
5+
b = int(input("enter b :"))
6+
c = int(input("enter c :"))
7+
d = b*b - 4 *a * c
8+
if d < 0 :
9+
print("roots are imaginary")
10+
else :
11+
r1 = (-b + math.sqrt(d)) / (2 * a)
12+
r2 = ( -b - math.sqrt(d))/(2 * a )
13+
print( r1)
14+
print (r2)

sales.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# program to calculate the salary of camera salesman .
2+
3+
# given basic salary , bonus rate , commission rate
4+
salary = 1500
5+
bonus_rate = 200
6+
commission_rate = 0.02
7+
8+
# taking input as no. of camera sale
9+
camera = int(input("no . of camera "))
10+
price = int(input("price :"))
11+
12+
# operations to calculate the bonus , commission , total salary
13+
bonus = bonus_rate * camera
14+
commission = camera * comission_rate * price
15+
total = salary + bonus + commission
16+
17+
print(bonus)
18+
print(commission)
19+
print(total)
20+

shorthand.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# shorthand operators
2+
# += , /= , *=
3+
4+
# basic program
5+
n = 100
6+
a = 2
7+
while a <n:
8+
print("%d" % a )
9+
a *= a

sum.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# program to sum
2+
# taking value of a and b
3+
a=23
4+
5+
b=45
6+
# these take value as string
7+
# but by typecasting manually change into int .
8+
print(int(a)+int(b))
9+

temprature.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# program to calculate the temperature
2+
# formula C=(F-32)/1.8
3+
4+
fahrenheit= 0.0
5+
print("Fahrenheit Celsius")
6+
while fahrenheit <= 250:
7+
celsius =(fahrenheit -32.0 ) /1.8 # here we calculate the celsius value
8+
print((fahrenheit , celsius))
9+
fahrenheit = fahrenheit + 25
10+

tuple.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# program to define tuple ;
2+
3+
data = ("Rahul", " 123" ," Btech")
4+
5+
print(data)

while.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# program while loop syntax.
2+
# initialization
3+
# while condition
4+
# statement
5+
# update
6+
n = 0
7+
while n<10:
8+
print(n)
9+
n += 1

year.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# program for getting months by days .
2+
# taking input as days
3+
days= int(input("enter days :"))
4+
months = days/30 # division
5+
days = days % 30 # modular operator for remainder
6+
print("Months = %d Days = %d " %(months , days ))
7+
8+

0 commit comments

Comments
 (0)