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
deff fn [24]
2 years ago
11

Write a Python program, which inputs an identifier/variable name from the user, decides if it is valid or invalid, and then prin

ts out Valid or Invalid.
Rules for identifiers are as follows:
- Can only be a sequence of letters, digits, and underscores
- Must start with letter or underscore
- Must not match with Python key words (if, elif, True, False, and, or, as, for)


This is what I have so far, but am stuck at:

userInput = input("Name: ")

for x in userInput:
if x >= 'a' and x <= 'z':
continue
if x >= 'A' and x <= 'Z':
continue
if x >= '0' and x <= '9':
continue
if x == '_':
continue
else:
valid = false
Computers and Technology
1 answer:
AveGali [126]2 years ago
5 0

Answer:

You can’t use reserved keywords as an identifier name.Python identifier can contain letters in a small case (a-z), upper case (A-Z), digits (0-9), and underscore (_).Identifier name can’t begin with a digit.Python identifier can’t contain only digits.Python identifier name can start with an underscore.There is no limit on the length of the identifier name.Python identifier names are case sensitive.

You might be interested in
Who are the people responsible for maintaining and controlling computer networks within an organization?
erik [133]

Answer:

Network Administrators

Explanation:

Network and computer systems administrators are responsible for the day-to-day operation of these networks. They organize, install, and support an organization's computer systems, including local area networks (LANs), wide area networks (WANs), network segments, intranets, and other data communication systems.

6 0
3 years ago
Which question is MOST important for an office to consider when upgrading to new software
Marina CMI [18]
Either B or D those are the most reasonable answers if it were up to me to answer i would pick B but that is up to you go ahead and try your best i hope u have a nice day ✨✌️✨
6 0
3 years ago
Write a 10 sentence paragraph about george washington and abraham lincoln and no plagiarism
Mamont248 [21]
10 sentence paragraph about George Washington and Abraham Lincoln and no playgiarism
8 0
3 years ago
Read 2 more answers
What are the objects in object-oriented programming language?
VMariaS [17]

Answer:

An object is an abstract data type with the addition of polymorphism and inheritance. Rather than structure programs as code and data, an object-oriented system integrates the two using the concept of an "object". An object has state (data) and behavior (code). Objects can correspond to things found in the real world.

hope it helps ya mate.

5 0
3 years ago
In what type of attack does the attacker send unauthorized commands directly to a database?
Delvig [45]
SQL injection. This is usually cause by the programmer not making the program parse incoming text, therefore allowing an attacker to input database commands.
4 0
4 years ago
Other questions:
  • Most Answers MOST ANSWERS
    11·2 answers
  • The BIOS feature that enables a hard drive to read or write several sectors at a time is called what?
    5·1 answer
  • Can i use both PLA and TPE or TPU for a single unit 3d printed prototype?
    13·1 answer
  • Show the stack with all activation record instances, including static and dynamic chains, when execution reaches position 1 in t
    14·1 answer
  • Write 2-3 lines about the Basic operations of computer
    5·1 answer
  • The processor of a computer communicates to the other parts of the computer through a code that consists of what?
    9·1 answer
  • Html code to hyperlink home.html​
    5·1 answer
  • What are some real-life situations where multi-dimensional arrays might be useful?
    8·1 answer
  • How to install an older version of prettier on yarn
    9·1 answer
  • What causes the hidden node problem in a wireless local area network (wlan)?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!