Count Upper Case and Lower Case Word in a string (Python)

 
Count Upper Case and Lower Case Word in a string     (Python)

def string_test(s):

    d={"UPPER_CASE":0, "LOWER_CASE":0}

    for c in s:

        if c.isupper():

           d["UPPER_CASE"]+=1

        elif c.islower():

           d["LOWER_CASE"]+=1

        else:

           pass

    print ("Original String : ", s)

    print ("No. of Upper case characters : ", d["UPPER_CASE"])

    print ("No. of Lower case Characters : ", d["LOWER_CASE"])


string_test('My Name is Gurpinder Singh')


Output :

Original String :  My Name is Gurpinder Singh

No. of Upper case characters :  4

No. of Lower case Characters :  18



String in alphabetical order in python

 # Python program to sort a string in alphabetical order


string = input("Enter the string : ")

j = 0

str1 = ""

temp = 0

str = list(string)


for i in range(0, len(str)):

for j in range(0, len(str)):

if(str[j] > str[i]):

temp = str[i]

str[i] = str[j]

str[j] = temp

print("The sorted string is : ")

print(str1.join(str))


 Output :

Enter the string : edcba
The sorted string is : 
abcde

Display a set and Remove the Double integer in Python

Display a set and Remove the Double integer in Python  


a = {1,2,2,3,3,3}

print(a)








Output

{1, 2, 3}

Display a Set in Serial Order in Python

 Display a Set in Serial Order in Python


a = {5,2,3,1,4}


# printing set variable

print("a = ", a)


# data type of variable a

print(type(a))


Output 


a =  {1, 2, 3, 4, 5}

<class 'set'>


Display one or more Character of String

 Program Display one or more Character of String 

 


s = 'Hello world!'


# s[4] = 'o'

print("s[4] = ", s[4])


# s[6:11] = 'world'

print("s[6:11] = ", s[6:11])



Output 

s[4] =  o
s[6:11] =  world

String Data Type in Python

 

String Data Type in Python  


s = "This is a string"

print(s)

s = '''A multiline

string'''

print(s)


Output 

This is a string

A multiline

string



Tuble Data Type in Python

 Tuble Data Type in Python 


thistuple = ("apple", "banana", "cherry")

print(thistuple[0])


Output 

apple

List Data Type in Python

 

List  Data Type in Python 


a = [5,10,15,20,25,30,35,40]


# a[2] = 15

print("a[2] = ", a[2])


# a[0:3] = [5, 10, 15]

print("a[0:3] = ", a[0:3])


# a[5:] = [30, 35, 40]

print("a[5:] = ", a[5:])


Output 

a[2] =  15

a[0:3] =  [5, 10, 15]

a[5:] =  [30, 35, 40]

Integer Data Types in Python

 Integer Data Types in Python   


a=5

print(a, "is of type", type(a))


a=2.0

print(a, "is of type", type(a))


a=1+2J

print(a, "is complex number?", isinstance(1+2j,complex))


Output : 

5 is of type <class 'int'>

2.0 is of type <class 'float'>

(1+2j) is complex number? True




Find The Number in Range Python

 

Find The Number  in Range     (Python) 

def test_range(n):

    if n in range(3,9):

        print( " %s is in the range"%str(n))

    else :

        print("The number is outside the given range.")

test_range(2)


Output :

5 is in the range


Volume of Sphere in Python


Find the Volume of Sphere in Python   

 r=float(input("Enter Radius :"))

pie=3.14
volume=(4.0/3.0)*pie*(r*r*r)
print("Volume of Sphere is : ",volume)
Output :
Enter Radius : 10
Volume of Sphere is :  4186.666666666667


 

Volume of cone In Python

Find the Volume of Cone in Python

 h=float(input("Enter Height :"))

r=float(input("Enter Radius :"))
pie=3.14 volume=pie*(r*r)*h/3
print("Volume of Cone is ", volume)

Output :

Enter Height :10 Enter Radius :5 Volume of Cone is 261.6666666666667


Single Table in Python

Display ant Table Input by the User in Python 


 n=int(input("Enter any Number "))

for i in range(1,11):

print('{0} * {1} = {2}'.format(n,i,i*n))

Output :

Enter any Number : 4 4 * 1 = 4 4 * 2 = 8 4 * 3 = 12 4 * 4 = 16 4 * 5 = 20 4 * 6 = 24 4 * 7 = 28 4 * 8 = 32 4 * 9 = 36 4 * 10 = 40

Find Triangle are Equilateral,Isosceles and Scalene Triangle With the help of if, elif,else Statement in python

Program to find the triangle are Equilateral , Isosceles  and Scalene in python 

 x=int(input("x :"))

y=int(input("y :"))
z=int(input("z :"))
if x == y == z:
print("Equilateral Triangle ") elif x==y or y==z or z==x:
print("Isosceles Triangle") else:
print("scalene Triangle")

Output :

x :10 y :45 z :10 Isosceles Triangle


Find The Area of Trapezoid in Python

 #Area of Trapezoid in Python

base1=float(input("Enter Base1 of a Trapezoid :"))
base2=float(input("Enter Base2 of a Trapezoid :"))
height=float(input("Enter Height of a Trapezoid :"))
area=0.5*(base1+base2)*height
print("Area of Trapezoid : ", area)

Output :

Enter Base1 of a Trapezoid :4 Enter Base2 of a Trapezoid :5 Enter Height of a Trapezoid :10 Area of Trapezoid : 45.0



Find Triangle are Isosceles or Not in Python

 # Isosceles Triangle

x=int(input("x :"))
y=int(input("y :"))
z=int(input("z :"))
if x==y or y==z or z==x:
print("Isosceles Triangle")
else:
print("Not Isosceles Triangle")


Output :

x : 12 y :41 z :12 Isosceles Triangle


Area of Square With the Help Of import math in Python

 #Area of Square with math.pow in python

import math
side=float(input("Enter side of square :"))
area=math.pow(side,3)
print("area of square : ", area)


Output :
Enter side of square :10
area of square : 1000.0


Area of Square in Python

 #Area of Square in Python


side=float(input("Enter side of square :"))
area=side*side
print("area of square : ", area)

Output :

Enter side of square :45 area of square : 2025.0


Resume in Python

Resume in Python 


 rafe=str(input("What are you making : "))

name=str(input("Name : "))

age=str(input("Age : "))

da=str(input("Date Of Birth : "))

print("PERSONAL INFORMATION")

fa=str(input("Father Name : "))

ma=str(input("Mother Name : "))

va=str(input("Village  : "))

print("QUALIFICATION ")

pera=str(input("Enter Percentage in 10th class : "))

per=str(input("Enter Percentage in 12th class : "))

ho=str(input("Hobby : "))

aim=str(input("Aim of life : "))

print("\n")

print("***********************************")

print("* \t", rafe  ,"\t          *")

print("* \t", name  ,"\t  *")

print("* \t", age  ,"\t                  *")

print("* \t", da  ,"\t          *")

print("* \t", "PERSONAL INFORMATION"  ,"\t  *")

print("* \t", fa  ,"\t          *")

print("* \t", ma  ,"\t          *")

print("* \t", va  ,"\t          *")

print("* \t", "QUALIFICATION"  ,"\t          *")

print("* \t", pera  ,"\t                  *")

print("* \t", per  ,"\t                  *")

print("* \t", ho  ,"\t  *")

print("* \t", aim  ,"\t  *")

print("***********************************")


Output :

What are you making : Resume
Name : Manpreet Singh
Age : 20
Date Of Birth : 12/05/2000
PERSONAL INFORMATION
Father Name : Manjit Singh
Mother Name : Manpreet Kaur
Village  : Kalanaur
QUALIFICATION 
Enter Percentage in 10th class : 74%
Enter Percentage in 12th class : 85%
Hobby : Playing Football
Aim of life : Software Developer


***********************************
* Resume                                             *
* Manpreet Singh                             *
* 20                                                     * 
* 12/05/2000                                     *
* PERSONAL INFORMATION     *
* Manjit Singh                                     *
* Manpreet Kaur                             * 
* Kalanaur                                     *
* QUALIFICATION                     *
* 74%                                             *
* 85%                                             *
* Playing Football                             * 
* Software Developer                     *
***********************************

Area of Parallelogram in Python

 # Area of Parallelogram

base=float(input("Enter Base of Parallelogram : "))
height=float(input("Enter Height of Parallelogram :"))
area=base*height
print("Area of Parallelogram : ",area)


Output :

Enter Base of Parallelogram : 5 Enter Height of Parallelogram :12 Area of Parallelogram : 60.0



Fibonacci Series with while loop in Python

Fibonacci Series with while loop in Python 👍

 n=int(input("Enter Value of n :"))

a=0
b=1
c=a+b
print(a)
print(b)
while c<=n:
print(c)
a=b
b=c
c=a+b


Output :

Enter Value of n :4 0 1 1 2 3

Fibonacci Series with def fib in Python


Fibonacci Series with  def fib in Python 

 n=int(input(" Enter any Number :"))

def fib(n):

    a=0

    b=1

    if n==1:

        print(a)

    else:

     print(a)

     print(b)

     for i in range(2,n):

         c=a+b

         a=b

         b=c

         print(c)

fib(n)      


Output :

 Enter any Number :4

0

1

1

2  


Factorial of a Number in Python

 Factorial of a  Number in Python

n=float(input("Enter a Number :"))

fact =1

while(n>=1):

      fact=fact*n

      n-=1

print("Factorial :",fact)


Output : 

Enter a Number :5

Factorial : 120.0



Volume of Cylinder in Python


Volume of Cylinder in Python 

 pi=22/7

height=float(input("Height of Cylinder :"))

radius=float(input("Radius of Cylinder : "))

volume=pi*radius*radius*height

print("Volume is : ",volume)


Output :

Height of Cylinder :15

Radius of Cylinder : 5

Volume is :  1178.5714285714284



Volume of Cube in Python

Volume of Cube in Python 

 import math

a=float(input("Enter The Value of a :"))

volume=math.pow(a,3)

print("volume :",volume)


Output :

Enter The Value Of a :4

volume : 64.0


Enter Character in Python

 Enter Character in Python  

nm=(input(" Name :"))

print(nm)


Output :

 Name :Harmanpreet Singh

Harmanpreet Singh



Area of Circle pi* in Python

Area of Circle pi* in Python 

 import math

radius=float(input("Enter radius of the circle : "))

area=math.pi*radius*radius

print("area of circle",area)


Output :

Enter radius of the circle : 4

area of circle 50.26548245743669



Area of circle in python Without pi*

Area of circle in python Without pi* 

 radius=float(input("Enter radius of the circle : "))

area=3.14*radius*radius

print("area of circle",area)


Output :

Enter radius of the circle : 5

area of circle 78.5



Area of Rectangle in Python

    

Area of Rectangle  in Python 

#Area of Rectangle 

width=float(input("Enter the width of the  Rectangle :"))

height=float(input("Enter the height of the  Rectangle :"))

area=width*height

print("area of the rectangle",area)

print("\n")


Output :

Enter the width of the  Rectangle :41

Enter the height of the  Rectangle :5

area of the rectangle 205.0



Add two Integer in Python

Add two Integer  in Python 


a= int(input("Enter First Number : "))

b= int(input("Enter Second Number : "))

 a=3

b=5

sum=a+b

print("sum of two numbers")

print(a,"+", b, "=",sum) 


Output : 


Enter First Number : 4
Enter Second Number : 4
sum of two numbers
4 + 4 = 8

Print Name in Python

Print Name in Python 


nm=str(input("Enter Name : "))

print(nm)



Output :

Enter Name : Gurnoor

Gurnoor


Count Upper Case and Lower Case Word in a string (Python)

  Count Upper Case and Lower Case Word in a string     (Python) def string_test(s):     d={"UPPER_CASE":0, "LOWER_CASE":...