You are on page 1of 3

DIGITAL ASSIGNMENT

SUBJECT: PROBLEM SOLVING AND PROGRAMMING IN PYTHON


COURSE CODE: CSE1001
NAME: CHARAN SRIDHAR BHOGARAJU
REGNO: 19BBS0094

1. STRING FORMATTING

# NAME:  CHARAN  SRIDHAR  BHOGARAJU


# REGNO:  19BBS0094

# STRING  FORMATTING 
print("The cost of mobile is {:.2f} $".format(30000))
print("The temperature is between {} and {} celcious".format(5,100,200))
print("The temperature is between {:-} and {:+} celcious".format(-5,10))
print("The cost of mobile is {:,} ruppes".format(1000000))
print("I have {:d} mobiles".format(0b111))
print("I have {:d} chocolates".format(0o110))
print("I have {:d} pens".format(0x0112))
print("I have {:o} laptops".format(0b1100))

# Use "e"  to  convert a number  in  scientific format


print("I have {:e} pens".format(345))
print("I have {:e} pens".format(0b1000))
print("I have {:e} pens".format(0x10))

# Using  %  to  show result  in  percentage


print("My score in CSE1001 is {:%}".format(.94))
print("My score in CSE1001 is {:.2%}".format(.94))
print("My score in CSE1001 is {:.3%}".format(.943262362))

# Using  < to 
print("I have {:<} notebooks".format(100))
print("I have {:<10} notebooks".format(100))
print("I have {:>15} notebooks".format(100))
print("I have {:^15} notebooks".format(100))

note,pen,pencil=20,10,5
print("I have {0} notebooks, {1} pens, {2} pencils".format(note,pen,pencil))
print(f"I have {note} {pen} {pencil}")
OUTPUT

2. COUNTING NUMBER OF INTEGERS

# NAME:  CHARAN  SRIDHAR  BHOGARAJU


# REGNO:  19BBS0094

listOfNumbers=list(map(int,input("Enter the Numbers: ").split()))
print(len(listOfNumbers))

OUTPUT
3. COUNTING ODD AND EVEN INTEGERS

# NAME:  CHARAN  SRIDHAR  BHOGARAJU


# REGNO:  19BBS0094

# FOR  LOOP
listOfNumbers=list(map(int,input("Enter the Numbers: ").split()))
count=0
for i in listOfNumbers:
    if i%2==0:
        count+=1
print("No of Even Integer is {}".format(count))
print("No of Odd Integers is {}".format(len(listOfNumbers)-count))
print()
# SHORT  CUT
print(f"The No of Even number is {len([i for i in listOfNumbers if i%2==0])}")
print(f"The No of Even number is {len([i for i in listOfNumbers if i%2!=0])}")

OUTPUT

You might also like