Categories
Python

String Palindrome in Python

 In this tutorial, I will show you how to write a string palindrome using Python programming.I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Program Listing

# palindrome.py
# Jake Rodriguez Pomperada,MAED-IT,MIT
# www.jakerpomperada.blogspot.com   www.jakerpomperada.com
# jakerpomperada@gmail.com
# Bacolod City, Negros Occidental Philippines
print("\n\n")
print("\tString Palindrome in Python")
print("\n")
str_value = input("Give a String : ")
print("\n")

if(str_value.lower() == str_value.lower()[:: - 1]):
   print("\tThe given string ", str_value.upper(), " is a Palindrome.\n")
else:
    print("\tThe given string ", str_value.upper(), " is not a Palindrome.\n")
print("\tEnd of Program")
Categories
Python

Count Number of Words From a Text File in Python

 In this program I will show you how to count the number of words from a text file using Python programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

Program Listing

data.txt

Python Programming is Fun and Profit
Professor Jake Rodriguez Pomperada


reading_textfile.py

# reading_textfile.py
# Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
# www.jakerpomperada.com www.jakerpomperada.blogspot.com
# jakerpomperada@gmail.com
# April 3, 2021
# Bacolod City, Negros Occidental

print()
print("\tCount Number of Words From a Text File in Python");
print()
try:
    print()
    fr = open("data.txt","r")
    for line in fr:
        line = line.strip("\n")
        print(line.upper())
        words = line.split()

        print()
        print('Total number of words: ', len(words))
        print("-----------------------------------------------")
        print()
        print("\tEND OF PROGRAM");
        print()
    fr.close()
except FileNotFoundError:
    print("File is not found")