n the expression v = f(i), (i) represents the input argument or parameter that is passed to the function f().
The v represents the output or result of the function f(). After the function is called with the input argument (i), it performs some computation or processing and returns a value, which is assigned to the variable v. The specific meaning of v will depend on the function and its intended purpose.
def m(b):
g = b.split(" ")
c = {}
for i in g:
if i in c:
c[i] = c[i] + 1
else:
c[i] = 1
return c
print(m("the quick brown fox jumps over the lazy dog"))
sir, I might not be able to complete this course in the allotted time for the course completion as my end session exams are coming so I would like to know how to complete the course even after the passing of my lab's approval date? and how can I evaluate my answers without a lab console so that I can complete this course and get certified?
I have reset your password, please try to login once again and let me know if it is working fine now. Also, this time try to type in the password instead of copy pasting it.
what if i have to sort huge data and then i have to call large number of keys with help of values??? i mean is there any method or function for this that we can use here????
You have to select the lines which you want to comment on, and then hit the `ctrl` and `/` on windows or Linux. if you are working on the Mac then you have to hit the `cmd` + `/`.
You can use the same keys to uncomment as well if you select the commented lines.
Hope this help.
Happy learning :)
P.S. I am sure you already look the jupyter notebook keyboard shortcuts(Help -> Keyboard shortcuts) which is actually fasten the development
Interesting question. Dictionary is like hashmap so it gives you the value at a key in O(1) time.
For your question, why do not you give it a shot yourself? :) Few ideas to solve this can be - Reverse the dictionary or use a dictionary comprehension to create a lookup dictionary and then use that to find the key from the value
Please help to read exception class , if any exception occure in try : except bolck, what i mean to ask how to get inner exception or Stack message in Python
These are codes shown as examples, you do not need to replicate them. You will have numerous coding assignments as you move forward in this course. Also, if you want to view the codes shown in the lecture video, you can refer to our GitHub repository for the latest version of these codes from the below link:
counts=dict()
names=['jayu','jayateerth','jayateertha','jaya','jayu']
for name in names:
if name not in counts:
counts[name]=1
else:
counts[name]=counts[name]+1
print(counts)
We are iterating through the names and checking if a name is already present as a key in the counts dictionary. If no, a new key-value pair with the name as key and value as 1 is created. Else, the count of the name is increased by 1. Hope this helps.
Hello Sandeep sir,my lab username and password is not working and showing invalid . earlier it was working . when I am starting my tuples videos it is not working now .kindly help
get method of a dictionary returns the value associated with the specified key. Here, counts.get(name,0) returns counts[name]; if that key doesn't't exist, then 0 will be returned. Thus, counts[name] = counts.get(name,0) +1 means, if the key is there, its values gets incremented by 1; else, count[name] becomes 0+1 which is 1. Hope this helps.
counts = dict()
names = ['cwen','csev','zqian','cwen']
for name in names :
if name not in counts :
count[name] = 1
else :
counts[name] = counts[name] +1
print(counts)
Try to stop your server(by clicking on control-panel option on top-right side of the notebook), then click on my server. After it connects, refresh your page. Hope this helps.
So how for calling a function we're giving it a name as f & x both are same, what's the difference.......??? to give the name to the function we can do f (x) = lambda x: x*x, isn't it??? then pass the argument.
Hi, I would like to request timestamps for these lectures on Youtube. I think it will be really helpful for referring back to the lecture for doubts and also in general for traversing the lecture.
why is this happening many times that when I'm posting screenshot together with question, the screenshot doesn't show up... then I've to post it again
@ 02:07:35 why I'm getting False or erroneous result,, results are incorrect, code is running okay.
Means why I'm getting "True" in result if I've defined it "False"
please suggest what's wrong. here the timing is referring the code which Sandeep is explaining, so I tried a similar type of code just to check different type of entry and what kinda results I'll get so here I'm talking about code and my result similar to Sandeep's explanation, it's not exactly same as he is telling.
This means my code won't check whether the tag housekeys is True or False, my code will just return the status of the TAG housekeys whether this tag is present in the bag or not, m I rt?
but then what is the use of this code which can't alert me if i lost my keys from my bog or forgot to keep it in my bag, if I run such code after my packing is done to get the status of my valuables present in the bag, means in physical / actual my bag contains those tags as well as tag's value or status.
Going by your example in your previous comment, here you are not checking whether the house key is present in your bag because you are not checking the value of the house key. Instead, you are checking the key in the dictionary that whether there is a place for house key present in your bag.
only checking Tag won't serve my purpose of checking the physical presence of my house key, suppose if Tag is present but physically I forgot to put my keys in the bag then how could I get an alarm regarding missing keys in tag housekeys...
then how to check the value means actually key is present or absent, etc ,, pls call if I'm not clear ,,, I understood ur point, just to check tag but my point is different so suggest me how can I do that
@ 02:07:35 why I'm getting False or erroneous result,, results are incorrect, code is running okay.
Means why I'm getting "True" in result if I've defined it "False"
please suggest what's wrong. here the timing is referring the code which Sandeep is explaining, so I tried a similar type of code just to check different type of entry and what kinda results I'll get so here I'm talking about code and my result similar to Sandeep's explanation, it's not exactly same as he is telling.
So how for calling a function we're giving it a name as f & x both are same, what's the difference.......??? to give the name to the function we can do f (x) = lambda x: x*x, isn't it??? then pass the argument.
it is being said that SORT on a LIST is done based on the key, but aren't we sorting it by value? Or what has been implied is that we have interchanged value and key with each other of dictionary items while appending it to another empty list?
word_count1=dict()
line1=input('Enter the text:') #user_input
words1=line1.split()
for word1 in words1:
word_count1[word1]=word_count1.get(word1,0)+1
bigcount is None
bigword is None
for word1,count in word_count1.items():
if count>bigcount:
bigword=word1
bigcount=count
print(bigword,bigcount)
OUTPUT:
Enter the text:this is a line of this text
text 7
Shouldn't the output be,
this 2
since 'this' is appearing 2 times in the text entered, which is the most no of times?
Python’s print() function comes with a parameter called ‘end’. By default, the value of this parameter is ‘\n’, i.e. the new line character. You can end a print statement with any character/string using this parameter.
Here they are referring to 0-based indexing where the index of a data structure, like an array, starts from zero. What this means is that the first element of that data structure starts from zero.
Our GitHub repository hosts all the latest notebooks that were referred in this course. You can clone the GitHub repository to access those notebooks in your lab using the following command (please try this command in the console and not the Jupyter notebook):
hi Team, i am receiving error while executing code same as in the class, i tried importing square and cubic function,but error throws does not find.please help.
Hi Team, I have completed Python foundations course and grabbed the knowledge by completing exercises. However both are showing 59% and 85% completed,please help me to shows correctly as possible as it is.
There are no chek functions in Python, which is why you are getting this error. You can try and use the map() function instead, it takes a list and a lambda function as an input.
I am facing an issue using jupyter besides the learning content. How do I open my own .py file in the jupyter in the same window on the side bar. Can someone please help me with this. I mean how do I open my python file in the Jupyter notebook in the playground.
The Jupyter notebook that opens on the right side of the topics are special notebooks for automated assessment by the playground. You cannot open a .py file on the right side, it would open in a new window.
hello sir please let me know about XP points and their uses. One more thing, despite writing the correct answers, sometimes tit shows error for which i have to refer hints or answer which results in reducing XP points.
I am so sorry to hear that your XPs were deducted despite answering the questions correctly. Would request you to let us know when you know it is the correct answer but it is showing it has incorrect.
The XPs help you see the hints or answers as and when required.
The *return* statement terminates the execution of a *function* and *returns* control to the calling *function*. Execution resumes in the calling *function* at the point immediately following the call. A *return* statement can also *return* a value to the calling *function*.
Python does not have an end command. It does have an exit command, however, that is different from return. You can use the exit command anywhere, however, return can only be used in a function. return, unlike exit, does not terminates the execution of the program. Rather it transfers the control to the main program that called the function.
*Lambda functions: *are operator can have any number of arguments, but it can have only one expression. It cannot contain any statements and it returns a function object which can be assigned to any variable. They can be used in the block they were created.
*def functions:* Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. They can be called and used anywhere we want. Hope that answers your queries.
In the first example, you are getting a handle to both the key, and the value. However, in the second one you are only printing the key (the value gets printed automatically with it).
Sir, one more question- what is error in following programming? def print_even(n): if n>0: result=0 return result result=result+2 return result if result>n: break elif n==0: return None
As mentioned in the course, every code that we show here is there in our GitHub repository. You need to clone it here using the following command: git clone https://github.com/cloudxla...
If you want, you can even fork it in your personal GitHub account.
We do not have a separate session on lambda function, however, let me explain it for you. A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression.
Hello sir, I am having confusion regarding conversion of list to dict & vise versa using buildin functions such as eg: name=["a","b","c"] name=dict(name) please give me an example to solve such problems. Thanks
You are using retv=f(i), this for every for loop this will be going to update the variable retv and at last you will be only remaining with the last value that is 16. But you would like to add every value to the list you need to use append retv.append(f(i)). Now you will be getting all the squares of the elements inside the list. All the best!
i want to know that when we use definite loop in iterating over a file,then whenever we write word ,it iterate word by word and when we write line,it iterates line by line. my doubt is that how the loop came to know that how it should iterate? do it came to know by just defining the variable name?
This automatic reply is just to let you know that we received your message and we’ll get back to you with a response as quickly as possible. During business hours (9am-5pm IST, Monday-Friday) we do our best to reply within a few hours. Evenings and weekends may take us a little bit longer.
If you have a general question about using CloudxLab, you’re welcome to browse our below Knowledge Base for walkthroughs of all of our features and answers to frequently asked questions.
If you have any additional information that you think will help us to assist you, please feel free to reply to this email. We look forward to chatting soon!
If you look at the syntax of a loop statement, it itself contains the type it needs to loop with. For example, when we say
for val in array: print(val) we are already telling the loop that we need to iterate an array using it's basic component, which is it's elements. So when we tell the loop to iterate a line using it's basic elements, it understand that we want to loop using words. The syntax of the loop gives it that information. Thanks.
i am a creating a text file in jupyter but when trying to open a file fhandle=open('shashank.txt') it showing the below error --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-1-545e38d889aa> in <module> ----> 1 fhandle=open('shashank.txt')
FileNotFoundError: [Errno 2] No such file or directory: 'shashank.txt'
Hi, Karthik. Tuple comparison is done elements by elements wise, if 1st is True, then it gives True. If rest is false then it is okay, but the first elements must be True then only True otherwise False. try this (3,5,3) < (2,3,1) , (1,5,3) < (2,3,1) etc. All the best!
Now I am getting Internal Server Error 500. How do I contact Admin to resolve this issue. Please help as I am unable to proceed with the course and loosing time. Thanks
I understand that you are trying to find the square root of the list if number passed but you have not defined the sq, you need to write a separate logic for this. the you can pass this as argument. Below code I have modified for you.
import math def sqrtf(a): rt=[] for i in a: v=math.sqrt(i) rt.append(v) return rt
t = 0 c = 0 while True: no = eval(input('Enter a number: ')) if no == 'done': break x = float(no) t = t + x c = c+1
avg = t / c print(avg)
NameError Traceback (most recent call last) <ipython-input-8-c69b74cc7145> in <module> 2 c = 0 3 while True: ----> 4 no = eval(input('Enter a number: ')) 5 if no == 'done': 6 break
In the continuous lectures (say Python Foundation Course), there is too much of revision in the proceeding videos. Please avoid this, as this caters to a lot of confusions and difficult to point/track that from where exactly the new topics are starting. Divide these in 2 different videos if required. For a continuous learner its really difficult to cope up.
For E.g. - In video "Python Dictionary and Tuples" 1:30 hours of video covers the last session which is "Basic building blocks of Python". For a learner who is watching these videos continuously without a break becomes very redundant. Please try and avoid this.
name = input('Enter the file name: ') handle = open(name) text = handle.read() words = text.split()
counts = dict() for word in words: counts[word] = counts.get(word, 0)+1
bigcount = None bigword = None
for word.count in counts.items(): if bigcount is None or count > bigcount: bigword = word bigcount = count print(bigword, bigcount)
after running above code on notebook it is showing following error Enter the file name: mbox.txt --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-17-cca6a4596c56> in <module> 1 name = input('Enter the file name: ') ----> 2 handle = open(name) 3 text = handle.read() 4 words = text.split() 5
FileNotFoundError: [Errno 2] No such file or directory: 'mbox.txt'
Please login to comment
259 Comments
v=f(i) what does (i) and v mean?
n the expression
v = f(i)
,(i)
represents the input argument or parameter that is passed to the functionf()
.The
Upvote Sharev
represents the output or result of the functionf()
. After the function is called with the input argument(i)
, it performs some computation or processing and returns a value, which is assigned to the variablev
. The specific meaning ofv
will depend on the function and its intended purpose.This comment has been removed.
This comment has been removed.
This comment has been removed.
This comment has been removed.
This comment has been removed.
sir, I might not be able to complete this course in the allotted time for the course completion as my end session exams are coming so I would like to know how to complete the course even after the passing of my lab's approval date? and how can I evaluate my answers without a lab console so that I can complete this course and get certified?
4 Upvote Sharev=f(i)
What it does??
r=[]
Why did you take this??
Upvote Sharer = [] -- Defines an empty list.
v = f(i) -- Accessing element at index i in type f
Upvote ShareHI team, Will I be getting a certificate post completion of this python course?
1 Upvote ShareHi Anagha
For free python course, there is no certificate provided
Regards
I am not able to sign in to lab.lab subcription validity is not expired
Upvote ShareHi,
I have reset your password, please try to login once again and let me know if it is working fine now. Also, this time try to type in the password instead of copy pasting it.
Thanks.
1 Upvote ShareThankyou Sir. its working now.
Upvote Sharehow to access the keys of a dictionary with the help of values???
Hi,
You can write something like:
Thanks.
Upvote Sharewhat if i have to sort huge data and then i have to call large number of keys with help of values??? i mean is there any method or function for this that we can use here????
Upvote ShareHi,
You may create a function for yourself. Iterate through dictionary and check for value and get the key.
Thanks.
Upvote ShareTop 10 most common words
Why are we appending in counts.items??
1st.append(key,val)
Please tell.
Hi,
Please share the screenshot of where exactly you are facing the issue.
Thanks.
Upvote ShareI did not understand.
r=[]
Why we are taking this??
How we are appending it and how it appends??
tell answer
Upvote ShareThis comment has been removed.
Hi Nirav,
In Python, this is one way to initialize a list it is similar to 'list()'. So both
and
are same.
So I think if this is a list object then `append` function will work to add a element in the list.
Hope this helps you. Happy learning :)
1 Upvote ShareHow do you comment multiple lines of code prefixing with with hash - do we have any option on Jupiter tooll bar?
Upvote ShareHi Chitra,
You have to select the lines which you want to comment on, and then hit the `ctrl` and `/` on windows or Linux. if you are working on the Mac then you have to hit the `cmd` + `/`.
You can use the same keys to uncomment as well if you select the commented lines.
Hope this help.
Happy learning :)
P.S. I am sure you already look the jupyter notebook keyboard shortcuts(Help -> Keyboard shortcuts) which is actually fasten the development
1 Upvote Sharewhenever I am creating a file and try to open it or run it from jupyter notebook, it says file not found
Hi,
Could you please give me more details about how you are creating a file, and how are you trying to run it?
Thanks.
Upvote ShareCan a dictionary have multiple keys with a single value ?
Upvote ShareHi,
Dictionary keys should be unique.
Thanks.
Upvote ShareCan I access a key form dictionary using vlaue ?
Upvote ShareHi Chaitra,
Interesting question. Dictionary is like hashmap so it gives you the value at a key in O(1) time.
For your question, why do not you give it a shot yourself? :) Few ideas to solve this can be - Reverse the dictionary or use a dictionary comprehension to create a lookup dictionary and then use that to find the key from the value
Upvote ShareThis comment has been removed.
Sir
For any doubt is there any possibility to contact you over the phone.
Regards
Rajesh
Upvote ShareHi,
For any doubts/queries, you can leave a comment below the respective tutorial and we will revert to you.
Thanks.
Upvote ShareThis comment has been removed.
hi how i can access your code from github
Upvote ShareHi,
You can find our GitHub repository at the below link:
https://github.com/cloudxlab/ml
Also, you can clone our repository using the below command on a web console:
Thanks.
Upvote Shareis " line" a special command when we open a text file and we need to go word by word rather than line by line what will we do??
Hi,
Could you please tell me which part of the tutorial are you referring to?
Thanks.
Upvote Sharewhen we open a text file to run in python
how to operate along each word
ex
fhandle = open("mbox.txt")
count = 0
for line in fhandle
this "line" is a variable or any command that we use to go line wise in a document
Hi,
This line is a variable.
Thanks.
Upvote ShareHi Team,
In python How to check whether file location is exists or not. For Example
with open("file lcoation") as f :
before calling a above script want to check file location is valid or not .
Upvote ShareHi,
Good question!
You can try the following:
You can go through the below link for more details:
https://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-without-exceptions
Thanks.
Upvote ShareHi Team,
Please help to read exception class , if any exception occure in try : except bolck, what i mean to ask how to get inner exception or Stack message in Python
Upvote ShareHi,
Please refer to this: https://stackoverflow.com/questions/1350671/inner-exception-with-traceback-in-python. Hope this helps.
Thanks.
Upvote Sharehi,
do we have to define mymap function every time as it is not running the code otherwise?
Upvote ShareHi,
These are codes shown as examples, you do not need to replicate them. You will have numerous coding assignments as you move forward in this course. Also, if you want to view the codes shown in the lecture video, you can refer to our GitHub repository for the latest version of these codes from the below link:
https://github.com/cloudxlab/ml/tree/master/python
Thanks.
Upvote Shareinput:
counts=dict()
names=['jayu','jayateerth','jayateertha','jaya','jayu']
for name in names:
if name not in counts:
counts[name]=1
else:
counts[name]=counts[name]+1
print(counts)
output:
Dint understand the logic of this code. Pl explain
Upvote ShareHi,
We are iterating through the names and checking if a name is already present as a key in the counts dictionary. If no, a new key-value pair with the name as key and value as 1 is created. Else, the count of the name is increased by 1. Hope this helps.
Thanks.
Upvote Shareok thank you
Upvote Sharea=list()
a[0]=1
print(a)
output:
I dint get this error for dict but getting error here in assigning for list.Can somebody tell why its showing error
Hi,
a is an empty list, but you're attempting to write to element
[0]
in the first iteration, which doesn't exist yet.Try the following instead, to add a new element to the end of the list:
Thanks.
Upvote Sharebut it is possible in empty dict
a=dict()
a["lenovo"]="sammy"
print(a)
Output:
Upvote ShareHi,
Yes you are right. This is possible with a dictionary but not with empty list. For empty list, we need to use append.
Thanks.
Upvote Shareok thank you
Upvote ShareWHY IN OTHER IDE IT SAYS THAT sq IS NOT DEFINED
Hi,
Could you please tell me where does it say "sq is not defined"?
Thanks.
Upvote SharePYChram
?
Upvote ShareHi,
Please check with the PyCharm help and FAQ for a solution.
Thanks.
Upvote Sharethis notebook never reads my any file
i don't why ->
Upvote ShareCan you show me the code?
Upvote Sharehere it is
Hi,
Please make sure the file exists and the provided path is correct.
Thanks.
Upvote SharePython ain't easy.
Upvote Sharehi There
I am facing 500 : Internal server error
1 Upvote ShareHi,
Are you still facing this issue? If yes, then please share a screenshot.
Thanks.
Upvote ShareHi there,
Facing below error:
Hi,
Are you still facing this issue?
Thanks.
Upvote ShareSorted now. Thanks :)
Upvote Sharedoes built in methods like max work on list with different data types
Upvote ShareHi,
Instead of me answering this for you, let me help you finding the answer. Please create a list and then use the max() function on the same.
Thanks.
Upvote ShareHi Sandeep sir , my username and password is still not working in jupiter notebook . Kindly help
Hi,
Your password has been reset. Please re-try now.
Thanks.
Upvote ShareHello Sandeep sir,my lab username and password is not working and showing invalid . earlier it was working . when I am starting my tuples videos it is not working now .kindly help
Hi Syed,
Sorry for the inconvenience, i have reset your password, please try again.
Upvote Shareplease explain
counts[name] = counts.get(name,0) +1
Upvote ShareHi,
get method of a dictionary returns the value associated with the specified key. Here, counts.get(name,0) returns counts[name]; if that key doesn't't exist, then 0 will be returned. Thus, counts[name] = counts.get(name,0) +1 means, if the key is there, its values gets incremented by 1; else, count[name] becomes 0+1 which is 1. Hope this helps.
Thanks.
Upvote Sharewhat is problem in
counts = dict()
Upvote Sharenames = ['cwen','csev','zqian','cwen']
for name in names :
if name not in counts :
count[name] = 1
else :
counts[name] = counts[name] +1
print(counts)
Hi,
Would suggest you to have a look at the answer.
Thanks.
Upvote ShareStill problem persists
Upvote ShareHi,
Try to stop your server(by clicking on control-panel option on top-right side of the notebook), then click on my server. After it connects, refresh your page. Hope this helps.
Thanks.
Upvote ShareNot able to connect Jupyter notebook
request your help
please explain word by word
def mymap (a,f):
r = [ ]
for i in a:
v = f(i)
r.append(v)
return r
mymap([1,2,3], sq)
plz exp r.append(v) this too
Upvote ShareHi,
We are passing the array to calculate the square of each item in the array and append the result.
Thanks.
Upvote Shareplease explain word by word
def mymap (a,f):
Upvote Sharer = [ ]
for i in a:
v = f(i)
r.append(v)
return r
mymap([1,2,3], sq)
Are there any sine/cosine functions in python library?
If yes, could you please explain how can I use them?
Upvote ShareHi,
Have a look at this https://www.geeksforgeeks.org/mathematical-functions-in-python-set-3-trigonometric-and-angular-functions/.
Thanks.
Upvote Share- what is wrong in this code?
Upvote ShareHi,
Try this:
Thanks.
Upvote ShareAt 00:48:10 ;\
both
>>> x = lambda x : x*x
>>> f = lambda x : x*x
>>> f(4)
16
are same .
So how for calling a function we're giving it a name as f & x both are same, what's the difference.......??? to give the name to the function we can do f (x) = lambda x: x*x, isn't it??? then pass the argument.
Hi Kranti,
The x was a typo, so Sandeep just changed the name to f.
Thanks.
Upvote ShareHi, I would like to request timestamps for these lectures on Youtube. I think it will be really helpful for referring back to the lecture for doubts and also in general for traversing the lecture.
1 Upvote ShareHi,
Thanks for your feedback. We have similar plans to make these videos more accessible. We would definitely consider this during our future updates.
Thanks.
Upvote Share@ 02:09:17 pls play the video for 1-2 min til 02:12:15 to understand the context... didn't understand after Sandeep finishes the explanation.
Hi Kranti,
It is returning False because y is of string type whereas there's nothing assigned to x and hence x and y are not equal.
Thanks and Regards,
Shubh Wadekar
1 Upvote ShareThis comment has been removed.
why is this happening many times that when I'm posting screenshot together with question, the screenshot doesn't show up... then I've to post it again
@ 02:07:35 why I'm getting False or erroneous result,, results are incorrect, code is running okay.
Means why I'm getting "True" in result if I've defined it "False"
please suggest what's wrong. here the timing is referring the code which Sandeep is explaining, so I tried a similar type of code just to check different type of entry and what kinda results I'll get so here I'm talking about code and my result similar to Sandeep's explanation, it's not exactly same as he is telling.
Hi Kranti,
'housekeys' in mybag
The above command is just checking if it exists in the dictinary and as it exists in the dictionary, it's returning True.
Thanks and Regards,
Shubh Wadekar
Upvote ShareThis means my code won't check whether the tag housekeys is True or False, my code will just return the status of the TAG housekeys whether this tag is present in the bag or not, m I rt?
but then what is the use of this code which can't alert me if i lost my keys from my bog or forgot to keep it in my bag, if I run such code after my packing is done to get the status of my valuables present in the bag, means in physical / actual my bag contains those tags as well as tag's value or status.
Hi,
Going by your example in your previous comment, here you are not checking whether the house key is present in your bag because you are not checking the value of the house key. Instead, you are checking the key in the dictionary that whether there is a place for house key present in your bag.
Thanks.
1 Upvote ShareGot it,
only checking Tag won't serve my purpose of checking the physical presence of my house key, suppose if Tag is present but physically I forgot to put my keys in the bag then how could I get an alarm regarding missing keys in tag housekeys...
then how to check the value means actually key is present or absent, etc ,, pls call if I'm not clear ,,, I understood ur point, just to check tag but my point is different so suggest me how can I do that
Upvote ShareHi,
You can traverse the dictionary and check the value of every key.
Thanks.
Upvote Share@ 02:07:35 why I'm getting False or erroneous result,, results are incorrect, code is running okay.
Means why I'm getting "True" in result if I've defined it "False"
please suggest what's wrong. here the timing is referring the code which Sandeep is explaining, so I tried a similar type of code just to check different type of entry and what kinda results I'll get so here I'm talking about code and my result similar to Sandeep's explanation, it's not exactly same as he is telling.
Hi Kranti,
Can you share the screenshot of the error with your code?
Thanks and Regards,
Shubh Wadekar
Upvote ShareI've written in context with the same question mentioned above, it has scrnsht.... Raj is attending it ,,,
Upvote ShareAt 00:48:10 ;\
both
>>> x = lambda x : x*x
>>> f = lambda x : x*x
>>> f(4)
16
are same .
So how for calling a function we're giving it a name as f & x both are same, what's the difference.......??? to give the name to the function we can do f (x) = lambda x: x*x, isn't it??? then pass the argument.
Upvote ShareHi,
I could not find the same mentioned at 00:48:10 timestamp of the video. Could you please check and let me know if it is at any other location.
Thanks.
Upvote Sharepls play the video for at least 10-20 sec you'll find it..
Upvote ShareHi,
I did, and I was unable to find it. Could you please recheck and share a screenshot maybe.
Thanks.
Upvote ShareIt has taken around 10 mins to do this because of refreshing stuff pls , enhance it
and why not pic is sending in 1st post
Hi,
I have replied to your query above. Please check.
Thanks.
Upvote Shareat 2:33:35,
it is being said that SORT on a LIST is done based on the key, but aren't we sorting it by value? Or what has been implied is that we have interchanged value and key with each other of dictionary items while appending it to another empty list?
Thanks.
Upvote ShareHi,
Here we are saving a key, value tuple in this list and we are sorting based on that key.
Thanks.
Upvote ShareWhat is a dynamic list? How is it different from a list in python?
Upvote ShareHi,
Good question!
A dynamic list in Python is a list which resizes everytime an element is appended to it.
Thanks.
Upvote ShareHi sir, can you please tell me more about 'Tuples are comparable' with examples?
Upvote ShareHi,
Would request you to refer to assessment 122.
Thanks.
Upvote ShareThis comment has been removed.
REFERENCE TIMESTAMP : 1:59:30
word_count1=dict()
line1=input('Enter the text:') #user_input
words1=line1.split()
for word1 in words1:
word_count1[word1]=word_count1.get(word1,0)+1
bigcount is None
bigword is None
for word1,count in word_count1.items():
if count>bigcount:
bigword=word1
bigcount=count
print(bigword,bigcount)
OUTPUT:
Shouldn't the output be,
this 2
since 'this' is appearing 2 times in the text entered, which is the most no of times?
Thanks.
Hi,
We do not have any provision for manual assessments. Would suggest you to post this on the discussion forum for peer review.
Thanks.
Upvote ShareHow do we run FOR loop in reverse in Python?
Upvote ShareHi,
Good question! Here's an example:
Thanks.
Upvote ShareOkay, for reversing in FOR loop, we have inbuilt 'reversed'.
Can you explain the print statement before the for loop and the one inside. What is end=" " doing?
Thanks.
Upvote ShareHi,
Python’s print() function comes with a parameter called ‘end’. By default, the value of this parameter is ‘\n’, i.e. the new line character. You can end a print statement with any character/string using this parameter.
Thanks.
Upvote ShareCan we call another lambda inside lambda function.
Upvote ShareHi,
Very interesting question! Yes, we can have nested lambda functions. Here is an example:
Thanks.
Upvote ShareHi,
at 00:45:25, how is print function returning NONE?
Thanks.
Upvote ShareHi,
This is because print does not return any value but prints it. So it is returning None.
Thanks.
Upvote ShareHi,
Can a module be imported inside a user defined function?
Thanks.
Upvote ShareHi,
It is always best practice to import modules at the starting/top of any program. However, one can also import inside a user-defined function.
Hope this helps.
Thanks.
1 Upvote ShareHi
Please help me out in getting the codes from Github, unable to find them.
Thanks
Upvote ShareHi Apratimkumar,
Try Python - Part I or follow this link: https://github.com/cloudxlab/ml/blob/master/python/Python%20-%20Part%20I.ipynb
Thanks
Upvote ShareThis comment has been removed.
Most of the time cloudx lab is not working it showing message "Not connected "
due to this lot of time get wasted , unable to do practice
Upvote ShareHi,
Would suggest you to go through our Fair Usage Policy to know about the best practices on using our lab:
https://cloudxlab.com/faq/6/what-are-the-limits-on-the-usage-of-lab-or-what-is-the-fair-usage-policy-fup
Thanks.
Upvote ShareHi sir,
I have completed 105/134 till now but i got a mail saying Your course progress till now is - 12%.
Sir, why is my progress is not getting saved.
Regards,
Aprajita
Hi,
Your overall course progress is 32%, are you still facing this issue?
Thanks.
Upvote ShareLambda function will work with square and cube command otherwise need to wrote the
Upvote ShareHi,
Are you facing any challenges with this?
Thanks.
Upvote ShareFor lambda functions expression is necessary to write or command like square and cube will work to run
Upvote ShareHi,
We have a separate topic on lambda functions, would request you to go through the same to get a better understanding.
Thanks.
Upvote ShareI am getting error in running simpleexp.py as error showing , pls help how can u get access the github files
Hi,
You need to mention the path for the file simpleexp.py. Also, you can clone out github repository using the following command in a web console:
git clone https://github.com/cloudxlab/ml
Thanks.
Upvote ShareI am getting invalid username or password for lab
Upvote ShareHi,
I checked from my end, you account is active and working fine. Would request you to type in your username and password instead of copy pasting them.
Thanks.
Upvote ShareHi,
This is the code for which assessment?
Thanks.
Upvote ShareCan we use lambda functions as password encryption algorythm?
Ref# Session video 41:23
Upvote ShareHi,
You can, but password encryption algorithms require something more sophisticated than that.
Thanks.
Upvote ShareThis comment has been removed.
counts = {'one':1,'Two':2,'three':3,'four':4}
for key1 in counts:
print(counts[key])
why its printing 4??
Upvote ShareHi,
Could you please tell me which slides, or which part of the video are you referring to?
Thanks.
Upvote ShareHello sir
Can you please tell me what is meant by zero-based or one-based?
Regards
Prithvi Kaushik
Upvote ShareHi,
Could you please tell me which slides, or which part of the video are you referring to?
Thanks.
Upvote ShareHi sir
I am referring to the question asked at 1:31:55 in the videos.
Thanks
Prithvi Kaushik
Upvote ShareHi,
Here they are referring to 0-based indexing where the index of a data structure, like an array, starts from zero. What this means is that the first element of that data structure starts from zero.
Thanks.
Upvote ShareHello,
Upvote ShareI am not getting the file words.txt and clown.txt for running this example given in Dictionary pdf
how to use github properly for this course please help
Upvote ShareHi,
Our GitHub repository hosts all the latest notebooks that were referred in this course. You can clone the GitHub repository to access those notebooks in your lab using the following command (please try this command in the console and not the Jupyter notebook):
git clone https://github.com/cloudxla... ~/ml
If you want to know more about GitHub, you can follow the below link:
https://product.hubspot.com...
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharehi Team,
i am receiving error while executing code same as in the class, i tried importing square and cubic function,but error throws does not find.please help.
Like the error statement, there is no function or variable called sq in the code
-- Praveen Pavithran
Upvote ShareHi Team,
Upvote ShareI have completed Python foundations course and grabbed the knowledge by completing exercises. However both are showing 59% and 85% completed,please help me to shows correctly as possible as it is.
It should be correct now.
Upvote ShareThere is no " print " here.Then how come the answer got printed ?
Upvote ShareLast...line of the code will be displayed.
Upvote ShareClosing ticket
-- Praveen Pavithran
Upvote ShareJupyter prints the value for such statement
-- Praveen Pavithran
Upvote Sharehow to install gotool lib from GIThub
Upvote ShareRakhi,
Could you tell me why you need this tool for this assignment?
-- Praveen Pavithran
Upvote ShareHi Team,
i am trying to run below code but i am getting error. please help and advise me solve the error.
my code:-
chek ([1, 2, 3], lambda x: x*2)
output:-
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-0c94f61af1f5> in <module>
----> 1 chek([1, 2, 3], lambda x: x*2)
NameError: name 'chek' is not defined
Upvote ShareHi,
Would request you to share a screenshot of your code and the error that you are getting.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHere is screenshot, pls help
Hi,
There are no chek functions in Python, which is why you are getting this error. You can try and use the map() function instead, it takes a list and a lambda function as an input.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareI am facing an issue using jupyter besides the learning content. How do I open my own .py file in the jupyter in the same window on the side bar. Can someone please help me with this. I mean how do I open my python file in the Jupyter notebook in the playground.
Upvote ShareHi,
The Jupyter notebook that opens on the right side of the topics are special notebooks for automated assessment by the playground. You cannot open a .py file on the right side, it would open in a new window.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharer = []
for i in range (5):
r[i]= int(input())
print (r)
what is wrong with this code?
Upvote Shareit is throwing an error....list assingment index out of range
Hi,
Would request you to share a screenshot of your code and the error that you are getting.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharetry below:
Upvote Sharer = []
for i in range(5):
x = int(input('Input value: '))
r.append(x)
print (r)
hello sir please let me know about XP points and their uses.
Upvote ShareOne more thing, despite writing the correct answers, sometimes tit shows error for which i have to refer hints or answer which results in reducing XP points.
Hi,
I am so sorry to hear that your XPs were deducted despite answering the questions correctly. Would request you to let us know when you know it is the correct answer but it is showing it has incorrect.
The XPs help you see the hints or answers as and when required.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharehow to make 2D array
Upvote ShareHi,
You can create a 2D array with the following code:
rows, cols = (5, 5)
arr = [[0]*cols]*rows
print(arr)
Please note that a 2D array is one which has more than 1 row and more than 1 column.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareThank you for reply sir,
Upvote ShareCan you give me any example how exicute
I mean make any 2 D array please
i know for 2D array atleasr 2 either row or column
Hi,
I have given the code to create a 2D array above. You can use that code in your Jupyter notebook to create a 2D array yourself.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharethank you sir i got it.
Upvote Sharehello sir what is meaning of return??
Upvote ShareHi,
The *return* statement terminates the execution of a *function* and *returns* control to the calling *function*. Execution resumes in the calling *function* at the point immediately following the call. A *return* statement
can also *return* a value to the calling *function*.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharelike end and it can also give some results
Upvote ShareHi,
Python does not have an end command. It does have an exit command, however, that is different from return. You can use the exit command anywhere, however, return can only be used in a function. return, unlike exit, does not terminates the execution of the program. Rather it transfers the control to the main program that called the function.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharewhat is different between lambda fuction and def function?
Upvote ShareHi,
*Lambda functions: *are operator can have any number of arguments, but it can have only one expression. It cannot contain any statements and it returns a function object which can be assigned to any variable. They can be used in the block they were created.
*def functions:* Functions help break our program into smaller and modular chunks. As our program grows larger and larger, functions make it more organized and manageable. They can be called and used anywhere we want.
Hope that answers your queries.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareThank you sir
Upvote ShareGetting below error
404 : Not Found
You are requesting a page that does not exist!
If i try to open a existing notebook it opens in new tab.
Upvote ShareHi,
Would request you to follow the method give in this link:
https://discuss.cloudxlab.c...
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHello Sir,
what is the basic difference between following codes. Both are returns same. I can't understand
Hi,
In the first example, you are getting a handle to both the key, and the value. However, in the second one you are only printing the key (the value gets printed automatically with it).
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHello Sir,
can I get github desktop for 32bit operating system?
Hi Souvik,
Would request you to check the minimum requirements on the GitHub website and check if it matches your system.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharethis file is not on github
Upvote ShareHi,
The link to the codes in our repository are given just below the slides. Here's the link:
https://github.com/cloudxla...
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHi team,
The file their is not the same as been used in Video, the content is very less than that of the demo shown.
Please share that actual one with all example used for explaination.
Upvote ShareHi,
Could you please let us know if there is any specific file that you found missing?
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharesir, what is the error?
Upvote ShareHi Sumit,
Since you are using elif, the return command below that should be indented to the right.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareSir, one more question- what is error in following programming?
Upvote Sharedef print_even(n):
if n>0:
result=0
return result
result=result+2
return result
if result>n:
break
elif n==0:
return None
Hi Sumit,
Are you getting any error with this code? If yes, then would request you to share a screenshot of your code and the error that you are getting,
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharesir, How I will get whatever you are typing in your jupyter notebook ?
Upvote ShareHi Sumit,
As mentioned in the course, every code that we show here is there in our GitHub repository. You need to clone it here using the following command:
git clone https://github.com/cloudxla...
If you want, you can even fork it in your personal GitHub account.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharesir in which session lamda function is explained??
Upvote ShareHi,
We do not have a separate session on lambda function, however, let me explain it for you. A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression.
Following are a couple of examples:
x = lambda a : a + 10
x = lambda a, b, c : a + b + C
x = lambda a, b : a * b
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHello Sir,
Why names call only first letter. Please explain?
Hi,
This is because you are mentioning the first index by using [0].
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHello sir,
I am having confusion regarding conversion of list to dict & vise versa using buildin functions such as eg:
name=["a","b","c"]
name=dict(name)
please give me an example to solve such problems.
Thanks
Hi,
You can convert a list into a dictionary like the following:
def Convert(a):
it = iter(lst)
res_dct = dict(zip(it, it))
return res_dct
# Driver code
lst = ['a', 1, 'b', 2, 'c', 3]
print(Convert(lst))
A list stores one element at a time, whereas a dictionary stores a key value pair. We need to keep that in mind while converting them.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareHello sir,
can you please help me to solve this error it is not taking sq and cube as function,how to resolve it.
Thanks
Hi,
You need to create a lambda function that would calculate the cube, and then pass that function as an argument to the function.
Thanks.
-- Rajtilak Bhattacharjee
Upvote ShareAppend is used to add something to the list. So when i run program instead of append why it is calculating only the last enitity's value in the array.
Hi, Nischal.
You are using retv=f(i), this for every for loop this will be going to update the variable retv and at last you will be only remaining with the last value that is 16.
But you would like to add every value to the list you need to use append retv.append(f(i)).
Now you will be getting all the squares of the elements inside the list.
All the best!
-- Satyajit Das
Upvote Shareok thanks. That was helpful
Upvote Sharei want to know that when we use definite loop in iterating over a
Upvote Sharefile,then whenever we write word ,it iterate word by word and when we
write line,it iterates line by line.
my doubt is that how the loop came to know that how it should iterate?
do it came to know by just defining the variable name?
Hello Disqus,
Thanks for contacting CloudxLab!
This automatic reply is just to let you know that we received your message and we’ll get back to you with a response as quickly as possible. During business hours (9am-5pm IST, Monday-Friday) we do our best to reply within a few hours. Evenings and weekends may take us a little bit longer.
If you have a general question about using CloudxLab, you’re welcome to browse our below Knowledge Base for walkthroughs of all of our features and answers to frequently asked questions.
- Tech FAQ <https: cloudxlab.com="" faq="" support="">
- General FAQ <https: cloudxlab.com="" faq=""/>
If you have any additional information that you think will help us to assist you, please feel free to reply to this email. We look forward to chatting soon!
Cheers,
Upvote ShareThe CloudxLab Team
Hi Mohini,
If you look at the syntax of a loop statement, it itself contains the type it needs to loop with. For example, when we say
for val in array:
print(val)
we are already telling the loop that we need to iterate an array using it's basic component, which is it's elements. So when we tell the loop to iterate a line using it's basic elements, it understand that we want to loop using words. The syntax of the loop gives it that information.
Thanks.
-- Rajtilak Bhattacharjee
Upvote Sharei am a creating a text file in jupyter but when trying to open a file fhandle=open('shashank.txt') it showing the below error
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-1-545e38d889aa> in <module>
----> 1 fhandle=open('shashank.txt')
FileNotFoundError: [Errno 2] No such file or directory: 'shashank.txt'
Upvote Sharei am not able to run %run first.py command...
Upvote Shareit is showing error: ERROR:root:File `'first.py'` not found.
Hi, Monika.
You can any python file from the terminal using command "python first.py ".
If you are using python3 version then python3 first.py.
All the best!
Upvote Sharehow is (1,2,3) < (2,3) true?
Upvote ShareHi, Karthik.
Upvote ShareTuple comparison is done elements by elements wise, if 1st is True, then it gives True. If rest is false then it is okay, but the first elements must be True then only True otherwise False.
try this (3,5,3) < (2,3,1) , (1,5,3) < (2,3,1) etc.
All the best!
Are arguments passed to functions in python passed by value or passed by reference?
Upvote Sharedef mymap(a,f):
r= [ ]
for i in a:
v=f(i)
r.append(v)
return r
mymap([2,3,5],lambda x:x*3)
its just giving [6],what is the error in code?
Upvote ShareHi, Sourabh.
It is giving [6, 9, 15].
Can you rerun the code
v=f(i)
r.append(v) should be kept inside the for loop.
All the best!
Upvote ShareThank you the issue that I reported earlier is resolved and I am able to access Jupyter
Upvote ShareNow I am getting Internal Server Error 500. How do I contact Admin to resolve this issue. Please help as I am unable to proceed with the course and loosing time. Thanks
Upvote Sharegetting 502 Bad Gateway error while accessing the Jupyter notebook/ playground. Please help
Upvote ShareHow t get the PPT in local file?
Upvote ShareI am not getting this Pyhon getting started file in my cloudx lab repository... please share.
Upvote ShareHi, Vivek.
Here are the Cloudxlab github repository.
================================
1) https://github.com/cloudxla...
2) https://github.com/cloudxla...
3) https://github.com/singhabh...
All the best!
Upvote Sharedef sqrtf(a,b):
rt=[]
for i in a:
v=b(i)
rt.append(v)
return rt
sqrtf([1,2,3,4],sq)
i am trying to use function inside a function but I am getting error , could you please help , below is the error
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-33-5b3a72ffd7ae> in <module>
5 rt.append(v)
6 return rt
----> 7 sqrtf([1,2,3,4],sq)
NameError: name 'sq' is not defined
Upvote ShareHi, RK.
I understand that you are trying to find the square root of the list if number passed but you have not defined the sq, you need to write a separate logic for this. the you can pass this as argument.
Below code I have modified for you.
import math
def sqrtf(a):
rt=[]
for i in a:
v=math.sqrt(i)
rt.append(v)
return rt
All the best!
Upvote Sharet = 0
c = 0
while True:
no = eval(input('Enter a number: '))
if no == 'done':
break
x = float(no)
t = t + x
c = c+1
avg = t / c
print(avg)
NameError Traceback (most recent call last)
<ipython-input-8-c69b74cc7145> in <module>
2 c = 0
3 while True:
----> 4 no = eval(input('Enter a number: '))
5 if no == 'done':
6 break
<string> in <module>
NameError: name 'done' is not defined
Upvote Shareyou can use intelligence on press "Tab" key.
Upvote ShareIn the continuous lectures (say Python Foundation Course), there is too much of revision in the proceeding videos. Please avoid this, as this caters to a lot of confusions and difficult to point/track that from where exactly the new topics are starting. Divide these in 2 different videos if required. For a continuous learner its really difficult to cope up.
For E.g. - In video "Python Dictionary and Tuples" 1:30 hours of video covers the last session which is "Basic building blocks of Python". For a learner who is watching these videos continuously without a break becomes very redundant. Please try and avoid this.
Regards Pankaj
Upvote ShareYes. I agree with you. Previously i have raised issue but no one has not response.
Upvote ShareYes. It is diffiicult to pick up from where the lesson left off the last time. It is therefore taking more time than it should to complete a lesson.
Upvote ShareHi, how to sort a list containing tuples.
Upvote ShareHi Sandeep
Upvote ShareCan we add null as key value in dictionary
'None' can be added as a key value in dictionary. 'Null' can't be added as a key value in dictionary.
eg:
dictn = {'one': 4, None:2}
print(dictn)
a = dictn.get(None,0) + 1
a
Output :
Upvote Share{'one': 4, None: 2}
3
name = input('Enter the file name: ')
handle = open(name)
text = handle.read()
words = text.split()
counts = dict()
for word in words:
counts[word] = counts.get(word, 0)+1
bigcount = None
bigword = None
for word.count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print(bigword, bigcount)
after running above code on notebook
it is showing following error
Enter the file name: mbox.txt
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-17-cca6a4596c56> in <module>
1 name = input('Enter the file name: ')
----> 2 handle = open(name)
3 text = handle.read()
4 words = text.split()
5
FileNotFoundError: [Errno 2] No such file or directory: 'mbox.txt'
________
above file is present in Files Section
Upvote ShareHi, Prashant.
Please check the correct path of the file.
All the best.
Upvote Shareplz guide on how to get the path
Upvote Sharedid you get the reply
Upvote ShareHi Sir, is there any difference when we use run simple.py and %run simple.py
Upvote ShareHi Sai, In Jupyter, we can only use %run
Upvote Sharecould you put mute when you drink or eat something?
Upvote ShareHi Eduardo, thank you for a constructive feedback. The Instructor has been communicated to.
Upvote Share