From 850068ea67295920c50459863fa33baa4610f1fa Mon Sep 17 00:00:00 2001 From: basmalah-kamal Date: Tue, 3 Jul 2018 22:33:04 +0200 Subject: [PATCH 1/2] add a file for built-in functions --- Functions/built-in-functions.py | 106 ++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 Functions/built-in-functions.py diff --git a/Functions/built-in-functions.py b/Functions/built-in-functions.py new file mode 100644 index 0000000..52158a8 --- /dev/null +++ b/Functions/built-in-functions.py @@ -0,0 +1,106 @@ +""" +This file contains some examples for built-in functions in python +they are functions that do certain things +I will explain +""" + + +#example 1 = .upper() +#added by @basmalakamal +str1 = "hello world" +print str1.upper() +#this how we use it and it is used to return the string with capital letters + +#example 2 = isupper() +#added by @basmalakamal +str2 = "I love coding" +print str2.isupper() +#this function returns a boolean it is used to see if all letters in the string are capital I have only one capital letter here +#so it returned False +#lets try again here +str3 = "PYTHON IS AWESOME" +print str3.isupper() #prints True + +#example 3 = lower() +#added by @basmalakamal +str4 = "BASMALAH" +print str4.lower() +#it returns the string with small letters + +#example 4 = islower() +#added by @basmalakamal +str5 = "Python" +print str5.islower() +#this function returns a boolean it is used to see if all letters in the string are small I have one capital letter here +#so it returned False +#lets try again here +str6 = "python" +print str6.islower() #prints True + +#example 5 = float() +#added by @basmalakamal +print float('12\n') +#we can use this one to input an integer and it will return a float depends on what you have written +#for example I wrote 12\n (\n means a space) so it returned 12.0 + + +#example 6 = id() +#added by @basmalakamal +print id(str6) +#it returns the identity of any object cause every object has an identity in python memory + +#example 7 = len() +#added by @basmalakamal + + + + + +#example 8 = int() +#added by @basmalakamal + + + +#example 9 = str() +#added by @basmalakamal + + + + +#example 10 = max() +#added by @basmalakamal + + + +#example 11 = sort() +#added by @basmalakamal + + +#example 12 = replace() +#added by @basmalakamal + + +#example 13 = append() +#added by @basmalakamal + +#example 14 = index() +#added by @basmalakamal + +#example 15 = split() +#added by @basmalakamal + +#example 16 = join() +#added by @basmalakamal + + + + + + + + + + + + + From 93811a71b75bf66ce978ce11ce603da2df55aa95 Mon Sep 17 00:00:00 2001 From: basmalah-kamal Date: Sat, 28 Jul 2018 21:04:32 +0200 Subject: [PATCH 2/2] add built-in functions --- Functions/.gitignore | 0 Functions/built-in-functions.py | 48 ++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 Functions/.gitignore diff --git a/Functions/.gitignore b/Functions/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Functions/built-in-functions.py b/Functions/built-in-functions.py index 52158a8..922b967 100644 --- a/Functions/built-in-functions.py +++ b/Functions/built-in-functions.py @@ -51,6 +51,10 @@ #example 7 = len() #added by @basmalakamal +str7 = "Programming" +print len(str7) +#you can use this function to return the length of any string (the number of characters), Plank spaces and symbols are also characters in python + @@ -58,40 +62,66 @@ #example 8 = int() #added by @basmalakamal +float1 = 7.0 +print int(float1) +#it converts the variable into an integer +#so the output will be only 7 #example 9 = str() #added by @basmalakamal +number1 = 7383929 +print str(number1) +#it converts the variable into a string #example 10 = max() #added by @basmalakamal +list1 = [5,6,7] +print max(list1) +#it returns the biggest value in a list so here the output will be 7 -#example 11 = sort() +#example 11 = replace() #added by @basmalakamal +list2 = ["a","b","d"] +a = list2.replace("d","c") +print a +#it will replace the string d with the string c so the value if a will be [a,b,c] -#example 12 = replace() -#added by @basmalakamal - -#example 13 = append() +#example 12 = append() #added by @basmalakamal +list3 = [1,2,3] +print list3.append(4) +#it will append bumber 4 to the list so it will be [1,2,3,4] -#example 14 = index() +#example 13 = index() #added by @basmalakamal +list4 = ["a","b","c"] +print list4.index("c") +#it will return the index of the string c which will be 2 -#example 15 = split() +#example 14 = split() #added by @basmalakamal +str8 = "Python" +a = str8.split() +print a +#it will create a list that has every character of the string as an item of it +#outputs ["P","y","t","h","o","n"] -#example 16 = join() +#example 15 = join() #added by @basmalakamal - +list5 = ["P","y","t","h","o","n"] +b = list5.join() +print b +#it is the opposite of the split function it will join all items together into a string +#outputs Python