Skip to content

my-courses.net

Python Courses & Exercises

Facebook Twitter Google Plus Linkedin Instagram YouTube Pinterest Tumblr VK Email RSS
  • Home
  • Python Courses
  • Python Exercises
  • Computer Glossary
  • Register

Month: May 2021

Solution Exercise 46: list of uppercase letters in a python string

May 31, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 46 Write a Python algorithm as a function which takes as parameter a string variable s and which returns the list of all uppercase characters found in s. Solution def listShift (s): # initialization of the list of capital letters l_maj = [] for x in s: if x.isupper (): l_maj.append (x) return l_maj#…

Solution Exercise 45: python algorithm that removes all integers from a list

May 29, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 45 Write a Python algorithm as a function which takes as parameter a list of real numbers L and which returns the list obtained from L by removing all integers. Solution # Function which removes integers from a listdef removeInt (L): # initialize the list obtained from L by removing all integers l_remove_int =…

Solution Exercise 44: python algorithm for moving the elements of a list

May 28, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 44 Write a Python algorithm as a function which takes as a parameter a list of integers L and which returns the list obtained from L by moving all zeros to the beginning of the list. Example if L = [7, 0, 11, 0, 25, 16, 0, 14], the algorithm returns the list: [0,…

Solution Exercise 43: python algorithm which removes negative elements from a list of numbers

May 27, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 43 Write a Python algorithm as a function which takes as parameter a list of integers L and which returns the list obtained from L by removing all negative numbers. Example if L = [7, -2, 11, -25, 16, -3, 14], the algorithm returns the list: [7, 11, 16, 14] Solution def deleteNegative(L): for…

Solution Exercise 42: even and odd list in python

May 26, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 42 Write a Python algorithm as a function which takes as a parameter a list of integers L and which returns the list obtained from L by inserting just after each number the string 'even' or 'odd' depending on the parity of number. Example if L = [2, 11, 25, 6, 14], the algorithm…

Solution Exercise 41: python algorithm which determines the list of integers whose last digit is even and the second is odd

May 25, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 41 Write an algorithm in python that extracts from a list of numbers the sublist of numbers whose last digit is even and the second is odd. Example if: L = [21, 14, 346, 728, 136, 19], the algorithm returns the list: [14, 136] Solution def listEvenOdd (L): # initialization of the list of…

Solution Exercise 40: python algorithm which determines the list of integers that end with an even number

May 24, 2021YOUNES DERFOUFIPython-ExercisesLeave a comment

Exercise 40 Write a Python algorithm that extracts from a list of numbers the sublist of numbers that end with an even number. Example: if L = [21, 14, 346, 728, 13, 19], the algorithm returns the list: [14, 346, 728] Solution def listEven (L): # initialization of the list of numbers that end with…

Posts navigation

Page 1 Page 2 … Page 5 Next

Search

Recent Posts

  • Solution Exercise 26: python algorithm to find all word beginning with the letter 'a'
  • Solution Exercise 25: python algorithm to reverse a given string
  • Solution Exercise 24: python program to check whether a word is palindrome or not
  • Solution Exercise 23: Python algorithm that extract the file extension
  • Solution Exercise 22: python algorithm that extract the first word in given text

Facebook Group

UserOnline

5 Users Online

Log In

14 + 3 =

  • Register
  • Lost your password?
© 2023 my-courses.net | Wordpress_Theme: Blogghiamo by CrestaProject.          CopyrightFrance.com