0% found this document useful (0 votes)
50 views2 pages

For in If and Elif and Elif and Else: "Enter A String"

The document contains code snippets that count the number of uppercase, lowercase, special characters and numbers in a string, rolls a dice multiple times randomly, prints all python files in a directory, checks if a path exists and creates/deletes a directory, and creates a bar chart in an Excel worksheet using data from a column. Functions like input, print, randint, glob, exists, mkdir, rmdir, load_workbook, Reference, BarChart and add_chart are used across code dealing with strings, random numbers, file paths, directories and Excel.

Uploaded by

piyush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

For in If and Elif and Elif and Else: "Enter A String"

The document contains code snippets that count the number of uppercase, lowercase, special characters and numbers in a string, rolls a dice multiple times randomly, prints all python files in a directory, checks if a path exists and creates/deletes a directory, and creates a bar chart in an Excel worksheet using data from a column. Functions like input, print, randint, glob, exists, mkdir, rmdir, load_workbook, Reference, BarChart and add_chart are used across code dealing with strings, random numbers, file paths, directories and Excel.

Uploaded by

piyush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

n=input("Enter a string")

upper=0
lower=0
special=0
number=0
for i in n:
if i>='65' and i<='90':
uper+=1
elif i>='97' and i<='122':
lower+=1
elif i>='48' and i<='57':
number+=1
else:
special+=1
print(upper)
print(lower)
print(special)

import random
class Dice:
def roll(self):
first=[Link](1,6)
second=[Link](1,6)
return first,second

m=int(input("Enter no of time want to roll a dice"))


r=Dice()
for i in range(m):
print([Link]())
print("Done playing")

from pathlib import Path

p=Path()
y=[Link]('*.py')
for file in y:
print(file)

p=Path("h1")
print([Link]())

p=Path("eccomerce")
print([Link]())

p=Path("eccomerce")
print([Link]())
O/P

[Link]

[Link]

[Link]

True

None
None
import openpyxl as xl
from [Link] import BarChart,Reference

wb=xl.load_workbook('[Link]')
sheet=wb['Sheet1']

for row in range(2,sheet.max_row+1):


cell=[Link](row,3)
corrected_price=[Link]*0.9
corrected_price_cell=[Link](row,4)
corrected_price_cell.value=corrected_price

values=Reference(sheet,
min_row=2,
max_row=sheet.max_row,
min_col=4,
max_col=4)
chart=BarChart()
chart.add_data(values)
sheet.add_chart(chart, "e2")

[Link]("[Link]")

You might also like