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
To maintain your body temperature, your body converts chemical potential energy into thermal energy T or F
PilotLPTM [1.2K]
True
This is physics btw
CPE --> TE
4 0
3 years ago
Select the steps for adding artwork into a placeholder on a presentation slide
Sloan [31]

Answer:

   Open the presentation that you want to add a slide to.

   In the pane that contains the Outline and Slides tabs, click Slides, and then click where you want to add a slide.

Explanation:

6 0
4 years ago
What is Colby Knox known for?
fiasKO [112]

Answer:The School in the Woods. Colby Knox is known for his work on The School in the Woods

Explanation:

7 0
3 years ago
Read 2 more answers
Rather than entering an IP address into our browser, we use a text-based address known as a(n
zalisa [80]

Answer:

url

Explanation:

7 0
2 years ago
Windows needs free space on the hard drive for normal operation, for defragmenting the drive, for burning CDs and DVDs, and for
REY [17]

Answer:

True

Explanation:

Windows writes temporary files to the hard disk which it uses as a cache during normal operation. These files are usually deleted automatically after the windows operation has been completed. If there is no free disk space available, some windows operations will fail to start and others will stop working

3 0
3 years ago
Other questions:
  • You’ve been hired to help with installing cable at a new office building for the local branch of the Social Security Administrat
    14·1 answer
  • If a pedestrian begins to cross my path when i have the right of way
    5·1 answer
  • Spoken word and written word are different because what
    9·1 answer
  • When replacing a system board in a laptop, which feature is a must?
    10·1 answer
  • What process periodically validates a user’s account, access control, and membership role on inclusion in a specific group?a. Re
    12·1 answer
  • Jerry wants to save his company money. He decides to move to open source software for his word processing needs. Jerry then down
    5·1 answer
  • How is a microkernel architecture different from a monolithic architecture?
    5·1 answer
  • Communication of a message between two processes implies which of the following? (A) Synchronization (B) Atomic operation (C) Bl
    11·1 answer
  • Write an expression that computes the integer average of the int variables exam1 and exam2 (both declared and assigned values).
    15·1 answer
  • The Brinley website will not let me search for questions anymore. It says “Search all you want in-app” and then covers the quest
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!