1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
myrzilka [38]
3 years ago
6

write a function that takes a string as parameter, return true if it’s a valid variable name, false otherwise. You can use keywo

rd module’s iskeyword() to determine if a string is keyword.
Computers and Technology
1 answer:
never [62]3 years ago
8 0

Answer:

The solution code is written in Python 3:

  1. import keyword  
  2. def checkValidVariable(string):
  3.    if(not keyword.iskeyword(string)):
  4.        return True  
  5.    else:
  6.        return False  
  7. print(checkValidVariable("ABC"))
  8. print(checkValidVariable("assert"))

Explanation:

Firstly, we need to import keyword module so that we can use its iskeyword method to check if a string is registered as Python keyword (Line 1).

Next, we create a function checkValidVariable that takes one input string (Line 3). Within the function body, we use iskeyword method to check if the input string is keyword. Please note the "not" operator is used here. So, if iskeyword return True, the True value will be turned to False by the "not" operator or vice versa (Line 4-5).

We test the function by passing two input string (Line 9-10) and we shall get the sample output as follows:

True

False

You might be interested in
What is the best option for sharing Word documents on a Microsoft network because it provides finer degrees of versioning contro
babymother [125]

Answer:

SharePoint Server

Explanation:

One drive you are not being provided with the opportunities like the versioning, check-outs and content approval. However, through SharePoint Server, you are being leveraged with all these features. Through versioning, you can update the document anytime, and also keep track of previous versions as well as the changes that you are making. Through content approval, you can ensure various members have approved permission privilege with them regarding the publication of the content.

Through checkout and check-ins the users can have control ob the new versions of the document as well as while the check-in the document, they can comment on the changes they have made.

6 0
3 years ago
A point is named by a lowercase letter. <br> a. True<br> b. False
Alik [6]
That is B False m8 that means mate btw xD please say thank you :P
4 0
3 years ago
Read 2 more answers
When breaking a problem down, you often encounter elements that you want to use repeatedly in your code. Sometimes it's appropri
ddd [48]

<u>Answer:</u>

<em>FUNCTION:</em>

  • A function does not require the number of times that the <em>code script needs to be executed </em>
  • When we go for large programming, ie. while creating projects, we can invoke function from one file to another based on the access <em>specifier mentioned for the function. </em>
  • There is a stack call created in the memory whenever a <em>function is called. </em>

<em>LOOP :</em>

  • Whereas the number of times that the loop has to be <em>executed must be defined </em>
  • A loop cannot be called, it can be used only the code block in <em>which it is present. </em>
  • There is not overhead of creating a stack since it is not invoked and there is no <em>transfer of control from one module to another </em>

8 0
3 years ago
Which Traffic Source dimensions does Google Analytics automatically capture for each user who comes to your site?A. Source, Keyw
LenaWriter [7]

For each user who comes to your site the google analytics automatically capture the traffic source dimensions Source, Medium, Campaign name.

<u>Explanation:</u>

Source:

  • There cannot be any reference to a website without an origin source.
  • The source is basically the origin of your traffic such as a search engine (google) or a domain (ex: Twitter).

Medium:

  • Every referral to a website also has a medium along with the source.
  • examples are -:  unpaid search, "cost per click", referral, mail.

Campaign name:

  • The campaign Name is the name referring to the google ads campaign.
5 0
3 years ago
When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages,
Anna11 [10]
<span>When widgets, or portable chunks of code, are embedded on html pages and thereby help increase the functionality of those pages, consumers embrace one of the greatest virtues of social media known as Collaboration.</span>
5 0
3 years ago
Other questions:
  • Graphic designers sometimes must adjust the spacing between letters so that the result looks right to them. This is called
    12·1 answer
  • To configure a router / modem, what type of IP interface configuration should you apply to the computer you are using?
    8·1 answer
  • I have to write this in Java, but i've never even learned it before and i'm completely lost
    12·1 answer
  • A digital designer might do computer animations for video games,<br> OA<br> True<br> OB<br> False
    12·2 answers
  • Write a nested loop to set values as follows: [0] [1] [2] [3] [4] [0] 1 2 3 4 5 [1] 1 2 3 4 5 [2] 1 2 3 4 5 [3] 1 2 3 4 5
    12·1 answer
  • Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter.
    6·1 answer
  • Imagine a machine that produces an output force that is five times larger
    11·1 answer
  • Select the correct answer from each drop-down menu. A company is recruiting for a web designer. What kind of candidate should th
    14·2 answers
  • Animals living in burrows under the ground is an interaction between the biosphere and the
    11·1 answer
  • A network of computers that provides access to information on the web.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!