Tuesday, November 5, 2019

format method in python

# -*- coding: utf-8 -*-
"""
Created on Wed Nov  6 07:28:23 2019
@author: Anil Durgam
"""

name="anil"
age=29
salary = 20000
print("{}'s age is {} and his salary is{}".format(name,age,salary))
print("{0}'s age is {1} and his salary is{2}".format(name,age,salary))
print("{x}'s age is {y} and his salary is{z}".format(x=name,y=age,z=salary))
print("{x}'s age is {y} and his salary is{z}".format(z=salary,x=name,y=age))

output:
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000
anil's age is 29 and his salary is20000

isalnum,isalpha,islower,isspace methods in python


"""
Created on Sun Nov  3 09:54:15 2019

@author: anil durgam
"""

s=input("Enter any character:")
if s.isalnum():
    print("Alpha numeric character")
    if s.isalpha():
        print("Alphabet character")
        if s.islower():
            print("Lower case alphabet character")
        else:
            print("Upper case alphabet character")
    else:
        print("It is a digit")
elif s.isspace():
    print("It is space character")
else:
    print("Non space Special character")


output:

Enter any character:5
Alpha numeric character
It is a digit



Enter any character:a
Alpha numeric character
Alphabet character
Lower case alphabet character


Enter any character:
It is space character
    

python class topic video