main

.py

School

University of North Carolina, Charlotte *

*We aren’t endorsed by this school

Course

5376

Subject

Computer Science

Date

Feb 20, 2024

Type

py

Pages

1

Uploaded by PrivateBadgerMaster993

Report
# Count the number of vowels in a given string def count_vowels(input_string): vowels = 'aeiouAEIOU' count = 0 for char in input_string: if char in vowels: count += 1 return count # Convert string to title case using def testing = 'atrium health' print('testing vowels:', count_vowels(testing)) def title_case(input_string): return input_string.title() test = 'atrium health' print('Original string:', test) print('New string:', title_case(test)) # Use python code to demonstrate string length using for loop def findLen(str): counter = 0 for i in str: counter += 1 return counter str = 'novant' print(findLen(str)) # Slicing strings data = 'X-DSPAM-Confidence: 0.8475' atpos = data.find(':') host = data[atpos+1:] print('Value:', float(host))
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help