Social Icons

Tuesday, December 8, 2020

Python-courses-python-exercises-python-dictionary

Exercise 93

1 - Write a function named count_characters() which accepts a character string and which returns the occurrence of the characters contained in the string in the form of a dictionary.
2 - Write a function named count_words() which accepts a character string and which returns the occurrence of the words contained in the string as a dictionary.

Solution

Question 1
def count_characters(s):
    d = dict ({})
    listUnique = []
    for c in s:
        if c not in listUnique and c!= ' ':
            listUnique.append (c)
            d [c] = s.count (c)
            
    return d
# Example
s = "Python Programming"
print (count_characters(s))
# The output is:
# {'P': 2, 'y': 1, 't': 1, 'h': 1, 'o': 2, 'n': 2, 'r': 2, 'g': 2, 'a': 1, 'm': 2, 'i': 1}
Question 2
def count_words (s):
    d = dict ({})
    listUnique = []
    listWords = s.split()
    for word in listWords:
        if word not in listUnique:
            listUnique.append(word)
            d[word] = listWords.count(word)
            
    return d
# Example
s = "Python is programming language and is the most used language"
print (count_words(s))
# The output is:
{'Python': 1, 'is': 2, 'programming': 1, 'language': 2, 'and': 1, 'the': 1, 'most': 1, 'used': 1}


Younes Derfoufi
my-courses.net

Friday, December 4, 2020

python-courses-python-exercises-python-tutorials-python-formation

Mastering Python Reference is an accelerated path with the intention to save you time and after gaining knowledge of the lessons you can begin writing workable applications (games, records visualizations, web programs, and lots more).

What is Python
Python is a popular fashionable-motive programming language that can be used for a wide kind of applications. It includes excessive-stage records structures, dynamic typing, dynamic binding, and plenty of more capabilities that make it as useful for complicated software improvement as it is for scripting or "glue code" that connects components collectively. it could additionally be extended to make device calls to almost all operating structures and to run code written in C or C++. because of its ubiquity and capacity to run on nearly every machine structure, Python is a typical language determined in a spread of various applications.

Friday, November 27, 2020

Python-courses-python-exercises

Exercise 92

Write a python program as a function which takes a string s as parameter and returns True if the string s contains at least one uppercase character and False otherwise.

Solution

def containsUpper(s):
    
     # define and initialize a variable which counts the number of capitals
     counter = 0
    
     # browse the characters in the string s
     for x in s:
          # increment the counter each time the character encountered is in uppercase
          if x.isupper ():
               counter = counter + 1
     if counter> 0:
          return True
     else:
          return False
# Example
print (containsUpper ("djangoFramework")) # prints True
print (containsUpper ("djangoframework")) # prints false


Younes Derfoufi
my-courses.net

Thursday, November 19, 2020

Python-courses-python-exercises-python-for-while

Exercise 89

Write a Python algorithm which determines the list of repeated charcters in given string. Example: if s = "Programming language", the algorithm returns the list:
['r', 'g', 'a', 'm', 'n']

Solution

# create a function to test if given character is repeated within a given string
def isRepeated(s,c):
    counter = 0
    for x in s:
        if x == c:
            counter = counter + 1
    if counter >= 2:
        return True
    else:
        return False
# create a function that returns the list of all repeated characters
def repeated(s):
    # initializing the list of all repeated characters
    listRepeated = []
    for x in s:
        if isRepeated(s , x) and x and x != " " and x not in listRepeated:
            listRepeated.append(x)
    return listRepeated

# Example
s = "programming language"
print("List of repeated characters in s: " , repeated(s)) 
# The output is : List of repeated characters in s:  ['r', 'g', 'a', 'm', 'n']


Younes Derfoufi
my-courses.net

Saturday, November 14, 2020

python-courses-python-exercises-python-tutorials-python-formation

What's Pthon ?
Python is a wellknown-reason programming language this is becoming ever extra popular for records science. businesses international are the use of Python to harvest insights from their records and advantage a competitive side. unlike different Python tutorials, this path specializes in Python in particular for data technological know-how. In our creation to Python route, you’ll study effective approaches to store and control facts, and useful records technology tools to start conducting your very own analyses. start DataCamp’s on line Python curriculum now.
Python, named after the British comedy institution Monty Python, is an interpreted, interactive, item-orientated programming language. Its flexibility lets in it to do many stuff, each massive and small. Python can be used to put in writing simple packages, however it also possesses the whole strength required to create complicated, massive-scale agency solutions. A number of the ways in which Python is used includes:
Python-courses-python-exercises-python-sets-python-inheritance

Exercise 93

Write a Python program which wrap a given string into a paragraph of given width Solution
import textwrap
def wrapText(s , w):
    return textwrap.fill(s,w)

# Example
s = "Python is open source programming language"
print(wrapText(s , 20))
"""
The out put is:
Python is open
source programming
language
"""


Younes Derfoufi
my-courses.net

Friday, November 13, 2020

features-Python-courses-python-exercises-python-oop

Exercise 91 ***

Write a python algorithm which determines the common words with maximum length of two strings text T1 and T2. Example if: T1 = "Python created by Guidorossum is open source programming language. Python was created on 1991" and T2 = "Python created by Guidorossum is the most popular programming language Guidorossum", the algorithm returns the list:
['Guidorossum', 'programming']

Solution

#creating a method which determines the list of common words in T1 and T2
def commonWords(T1 , T2):
    # converting the texts into lists
    listWords_in_T1 = T1.split()
    listWords_in_T2 = T2.split()

    # initializing the common words
    listCommon_words = []
    for word in listWords_in_T1 :
        if word in listWords_in_T2 and word not in listCommon_words:
            listCommon_words.append(word)
    return listCommon_words

# Creating a methode that determines the common word with maximum length
def commonMax(T1, T2):
    listCommon_words = commonWords(T1 , T2)
    # initializing the maximum length
    maxLength = 0
    for word in listCommon_words:
        if len(word) >= maxLength:
            maxLength = len(word)
            
    # searching the the common words of maximum length
    listCommonWordMax = []
    for word in listCommon_words:
        if len(word) == maxLength:
            listCommonWordMax.append(word)
    return listCommonWordMax

T1 = "Python created by Guidorossum is open source programming language. Python was created on 1991"
T2 = "Python created by Guidorossum is the most popular programming language Guidorossum"
print(commonMax(T1 , T2))
# The output is: ['Guidorossum', 'programming']


Younes Derfoufi
my-courses.net

Category Of Mobile Courses

Actualités (644) Adsense (1) Affiliation (1) Algebraic Topology (2) Algorithmic (1) all-news (30) Android (5) Android App (8) Android app without code (4) Android Apps (252) Android Development (4) Android download (2) Android OS (3) AngularJS (1) Automata theory and formal language (5) C programming (5) Category and Functor (8) CMS (3) Computer Glossary (18) Create Mobile App With Ionic Framework (2) CSS (2) CSS-Cascading-Style-Sheets (4) Developpement Java (13) Differential Geometry (1) Django-Python-Framework (8) dropshiping (26) Earn Money by Internet (4) Emplois (23) Framework php (2) Fraud (2) HTML (7) Java For Beginners (10) Javascript (12) Kotlin Programming Language (8) Kotlin For Mobile Android (1) Linux Download (2) Marketing (5) Mobile (3) Mobile Courses (4) Mobile Marketing (4) MoneyGram (1) News (721) Node.js (5) Open Source (1) Photoshop (1) Protect Computer (1) Python (35) Python BeautifulSoup (1) Python For Data Science (2) Python-Books (6) Python-DVD-Training (1) Python-Exercises (208) Python-Framework (1) Python-IDE (1) Python-Modules (1) Python-pdf (2) Python-pyQt (1) Référencement (2) Script PHP (2) Security (6) SEO (1) Snipping Tool: Faq (1) Social Networks (1) Source Code (1) Statistics With SPSS (2) Surveillance Software (1) Travail à domicile (6) Tutoriels php en vidéos (2) Tutoriels-MySql (6) tutoriels-php (19) Utilitaires (1) VPS (1) Web Hosting (1) Webcam (1) Webmarketing (11) Western Union (1) Windows 10 (1) Windows 7 (4) Windows 7 Faq (2) Windows 8 (1) Windows Accessories (1) Windows Download (8) Windows Drivers (1) Windows Fonts (1) Windows Power Shell (2) Windows Registry (2) Windows Security (18) Windows Software (2) Windows Spyware (2) Windows utilities (3) Windows Virus (2) Windows Vista (3) Windows Wireless (1) Windows xp (1) Wordpress (1)
 

Sample text

Sample Text

 
Blogger Templates