Skip to content

Instantly share code, notes, and snippets.

View Tafhimbn's full-sized avatar
🏠
Working from home

Tafhim Bin Nasir Tafhimbn

🏠
Working from home
View GitHub Profile
@Tafhimbn
Tafhimbn / file_open_find_no_of_characters.py
Last active April 5, 2023 21:50
Using the file school_prompt2.txt, find the number of characters in the file and assign that value to the variable num_char
#Using the file school_prompt2.txt, find the number of characters in the file and assign that value to the variable num_char
file=open("school_prompt2.txt","r")
st=file.read()
num_char = 0
for ch in st:
num_char+=len(ch)
file.close()
@Tafhimbn
Tafhimbn / task.py
Last active May 30, 2020 10:46
Write code that uses the string stored in sent and creates an acronym which is assigned to the variable acro. The first two letters of each word should be used, each letter in the acronym should be a capital letter, and each element of the acronym should be separated by a “. ” (dot and space). Words that should not be included in the acronym are…
stopwords = ['to', 'a', 'for', 'by', 'an', 'am', 'the', 'so', 'it', 'and', 'The']
sent = "The water earth and air are vital"
acro = ""
words = sent.split()
for ch in words:
if ch not in stopwords:
acro = acro + ch[:2]
if ch != words[-1]:
acro += ". "