Skip to content

Commit e539ed6

Browse files
Add files via upload
0 parents  commit e539ed6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+492
-0
lines changed

pr10_1upperlowercase.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def string_test(s):
2+
d={"UPPER_CASE":0, "LOWER_CASE":0}
3+
for c in s:
4+
if c.isupper():
5+
d["UPPER_CASE"]+=1
6+
elif c.islower():
7+
d["LOWER_CASE"]+=1
8+
else:
9+
pass
10+
print ("Original String : ", s)
11+
print ("No. of Upper case characters : ", d["UPPER_CASE"])
12+
print ("No. of Lower case Characters : ", d["LOWER_CASE"])
13+
14+
string_test('My name is Stuti Gujarathi')

pr10_2randomfloat.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import random
2+
for x in range(6):
3+
print('{:04.3f}'.format(random.uniform(x, 100)), end=' ')

pr11_1primeornot.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def test_prime(n):
2+
if (n==1):
3+
return False
4+
elif (n==2):
5+
return True;
6+
else:
7+
for x in range(2,n):
8+
if(n % x==0):
9+
return False
10+
return True
11+
print(test_prime(14))

pr11_2factorial.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def factorial(n):
2+
if n == 0:
3+
return 1
4+
else:
5+
return n * factorial(n-1)
6+
n=int(input("Input a number to compute the factiorial : "))
7+
print(factorial(n))

pr12_1college.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import file;
2+
name = input("Enter the College name:")
3+
file.displayMsg(name)

pr12_3calendar.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import calendar
2+
yy=2021
3+
mm=7
4+
print(calendar.month(yy,mm))

pr12_circlearea.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import math
2+
radius = float(input("Enter radius of circle: "))
3+
area = radius*radius* math.pi
4+
cir=math.pi*2*radius
5+
print(" Area Of a Circle = ",area)
6+
print(" circumference Of a Circle = ",cir)

pr13_1arithmatic.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import numpy
2+
# Two matrices are initialized by value
3+
x = numpy.array([[1, 2], [4, 5]])
4+
y = numpy.array([[7, 8], [9, 10]])
5+
# add()is used to add matrices
6+
print ("Addition of two matrices: ")
7+
print (numpy.add(x,y))
8+
# subtract()is used to subtract matrices
9+
print ("Subtraction of two matrices : ")
10+
print (numpy.subtract(x,y))
11+
# divide()is used to divide matrices
12+
print ("Matrix Division : ")
13+
print (numpy.divide(x,y))
14+
print ("Multiplication of two matrices: ")
15+
print (numpy.multiply(x,y))

pr1_version.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sys
2+
print("Python Version")
3+
print(sys.version)
4+
print("Version info.")
5+
print(sys.version_info)

pr2_msbte.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print('MSBTE')

pr2_name.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
2+
Type "help", "copyright", "credits" or "license()" for more information.
3+
>>> print('Stuti Gujarathi')
4+
Stuti Gujarathi
5+
>>>

pr3_areanperimeter.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
print("Enter the value of a: ")
2+
a=int(input())
3+
print("Area of square: ", a*a)
4+
print("Perimeter of square: ", 4*a)

pr3_areaofrect.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
print("Enter the value of l: ")
2+
l=int(input())
3+
print("Enter the value of b: ")
4+
b=int(input())
5+
sum=0
6+
7+
8+
print("Area of rectangle: ", l*b)

pr3_bytes.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bits=float(input("Enter the number in bits:"))
2+
3+
Terabytes = bits/(876093022208)
4+
Gigabytes = bits/(8589934592)
5+
Megabytes = bits/(8388608)
6+
print("Value in Terabytes is:" ,Terabytes)
7+
print("Value in Gigabytes is:" ,Gigabytes)
8+
print("Value in Megabytes is:" ,Megabytes)

pr3_currency.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
usd = float(input("Enter currency in USD: "))
2+
inr = usd * 73
3+
4+
print("The currency in INR is",round(inr,2))

pr3_sqrroot.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
print("Enter the value of n: ")
2+
n= int(input())
3+
sum=0
4+
for i in range(1, n+1):
5+
sum = n*n
6+
print("Square root is:", sum)

pr3_swap.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
print('Enter the value of x: ')
2+
x=int(input())
3+
print('Enter the value of y: ')
4+
y=int(input())
5+
6+
print('Before Swapping')
7+
print('The value of x:', x)
8+
print('The value of y:', y)
9+
10+
temp=x
11+
x=y
12+
y=temp
13+
14+
print('After Swapping')
15+
print('The value of x:', x)
16+
print('The value of y:', y)
17+
18+

pr3_volumensur.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pi=22/7
2+
height=float(input('Height of cylinder: '))
3+
radian=float(input('Radian of cylinder: '))
4+
volume=pi*radian*radian*height
5+
sur_area=((2*pi*radian)*height)+((pi*radian**2)*2)
6+
print("Volume of cylinder: ", volume)
7+
print("Surface Area: ",sur_area)

pr4_absnumber.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
number = int(input("number = "))
2+
3+
if number< 0:
4+
print(-number)
5+
else:
6+
print(number)

pr4_evenodd.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
print("Enter value of n: ")
2+
n=int(input())
3+
if n%2==0:
4+
print("Even Number")
5+
else:
6+
print("Odd Number")

pr4_grades.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
print("Enter marks of oops: ")
2+
a=int(input())
3+
print("Enter marks of dsu: ")
4+
b=int(input())
5+
print("Enter marks of java: ")
6+
c=int(input())
7+
print("Enter marks of python: ")
8+
d=int(input())
9+
print("Enter marks of C: ")
10+
e=int(input())
11+
total=a+b+c+d+e
12+
print("Total marks: ",total)
13+
if total>=75:
14+
print("Distinction")
15+
elif total>=60:
16+
print("A Grade")
17+
elif total>=50:
18+
print("B Grade")
19+
elif total>=40:
20+
print("C Grade")
21+
else:
22+
print("Fail")

pr4_greaterno.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
print("Enter the value of first number: ")
2+
x=int(input())
3+
print("Enter the value of second number: ")
4+
y=int(input())
5+
print("Enter the value of third number: ")
6+
z=int(input())
7+
if (x>y) and (x>z):
8+
print("First number is greater")
9+
elif (y>x) and (y>z):
10+
print("Second number is greater")
11+
else:
12+
print("Third number is greater")

pr4_leapyr.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
print("Enter the year: ")
2+
n= int(input())
3+
if n%4==0:
4+
print(n," is a leap year")
5+
else:
6+
print(n,"is not a leap year")

pr4_posnegzero.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n = float(input("Enter a number: "))
2+
if n > 0:
3+
print("Positive number")
4+
elif n == 0:
5+
print("Zero")
6+
else:
7+
print("Negative number")

pr5(c)numberpattern.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
p = input("first value : ")
2+
q = input("second value : ")
3+
j = 0
4+
k = int(input("rows you want? : "))
5+
while k >= 1:
6+
print(" "*j + (k-1)*(p+q) +p+ " "*j)
7+
k = k-1
8+
j=j+1

pr5_1(a)fourstar.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
print("Enter value of n: ")
2+
n=int(input())
3+
for i in range(0,n):
4+
for j in range(0, i+1):
5+
print("*",end="")
6+
print("")

pr5_1(b)star.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
print ("Enter the limit")
2+
rows = int(input())
3+
4+
#top half
5+
k = 0
6+
for i in range(1, rows + 1):
7+
# print spaces
8+
for j in range (1, (rows - i) + 1):
9+
print(end = " ")
10+
11+
# let's print stars
12+
while k != (2 * i - 1):
13+
print("*", end = "")
14+
k = k + 1
15+
k = 0
16+
17+
# add a line break
18+
print()
19+
20+
#bottom half
21+
k = 2
22+
m = 1
23+
for i in range(1, rows):
24+
# print spaces
25+
for j in range (1, k):
26+
print(end = " ")
27+
k = k + 1
28+
29+
# print star
30+
while m <= (2 * (rows - i) - 1):
31+
print("*", end = "")
32+
m = m + 1
33+
m = 1
34+
35+
#add a line break
36+
print()

pr5_evennos1to100.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
maximum = int(input(" Please Enter the Maximum Value : "))
2+
3+
number = 1
4+
5+
while number <= maximum:
6+
if(number % 2 == 0):
7+
print("{0}".format(number))
8+
number = number + 1

pr5_factorialno.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
num = int(input("Enter a number: "))
2+
3+
factorial = 1
4+
5+
6+
if num < 0:
7+
print("Sorry, factorial does not exist for negative numbers")
8+
elif num == 0:
9+
print("The factorial of 0 is 1")
10+
else:
11+
for i in range(1,num + 1):
12+
factorial = factorial*i
13+
print("The factorial of",num,"is",factorial)

pr5_fibonacci_series.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
nterms = int(input("Number of terms: "))
2+
3+
# first two terms
4+
n1, n2 = 0, 1
5+
count = 0
6+
7+
# check if the number of terms is valid
8+
if nterms <= 0:
9+
print("Please enter a positive integer")
10+
elif nterms == 1:
11+
print("Fibonacci sequence upto",nterms,":")
12+
print(n1)
13+
else:
14+
print("Fibonacci sequence:")
15+
while count < nterms:
16+
print(n1)
17+
nth = n1 + n2
18+
# update values
19+
n1 = n2
20+
n2 = nth
21+
count += 1

pr5_palindrome.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
n=int(input("Enter number:"))
2+
temp=n
3+
rev=0
4+
while(n>0):
5+
dig=n%10
6+
rev=rev*10+dig
7+
n=n//10
8+
if(temp==rev):
9+
print("The number is a palindrome!")
10+
else:
11+
print("The number isn't a palindrome!")

pr5_reverseno.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n=int(input("Enter number: "))
2+
rev=0
3+
while(n>0):
4+
dig=n%10
5+
rev=rev*10+dig
6+
n=n//10
7+
print("Reverse of the number:",rev)

pr5_sumnaturalnos.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
num = int(input("Enter a number: "))
2+
3+
if num < 0:
4+
print("Enter a positive number")
5+
else:
6+
sum = 0
7+
# use while loop to iterate until zero
8+
while(num > 0):
9+
sum += num
10+
num -= 1
11+
print("The sum is", sum)

pr5_sumofdigits.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
n=int(input("Enter a number:"))
2+
total=0
3+
while(n>0):
4+
dig=n%10
5+
total=total+dig
6+
n=n//10
7+
print("The total sum of digits is:",total)

pr6_commonlist.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
color1 = "Red", "Green", "Orange", "White", "Blue"
2+
color2 = "Black", "Blue", "White", "Pink", "Red"
3+
print(set(color1) & set(color2))

pr6_evennolist.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
2+
3+
for num in list1:
4+
5+
6+
if num % 2 == 0:
7+
print(num, end = " ")

pr6_largenoinlist.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# list of numbers
2+
list1 = [10, 20, 30 , 40 , 50, 100]
3+
4+
list1.sort()
5+
6+
print("Largest element is:", list1[-1])

pr6_muloflist.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
def multiply_list(items):
2+
tot = 1
3+
for x in items:
4+
tot *= x
5+
return tot
6+
print(multiply_list([1,5,10]))

pr6_reverselist.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def Reverse(lst):
2+
return [ele for ele in reversed(lst)]
3+
4+
lst = [10, 11, 12, 13, 14, 15,20]
5+
print(Reverse(lst))

pr6_smallnoinlist.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# list of numbers
2+
list1 = [10, 20, 30, 40, 50, 100]
3+
4+
list1.sort()
5+
6+
print("Smallest element is:", *list1[:1])

0 commit comments

Comments
 (0)