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
alexandr1967 [171]
3 years ago
5

Assure that major, minor, sub1 and sub2 each contain four digit numbersIf less than four digits are entered in major OR minor OR

sub1 OR sub1, then the fieldshould be padding with zeroes at the beginning (e.g., if the user enters "33", then thescript should convert this to a four digit number "0033", if they enter "0", the scriptshould convert this to "0000")Blank fields are not allowed in the major, minor, sub1. sub2 or ta fieldsHowever, if an account number containing ALL zeroes is INVALID (i.e., if major=0000AND minor=0000 AND sub1=0000 AND sub2=0000, then the journal entry isconsidered INVALID because there will never be an Account Number composed of allzeroes)

Computers and Technology
1 answer:
Zigmanuir [339]3 years ago
4 0

Answer:

import re

#section 1

while True:

   try:

       major=input('Enter Major: ')

       if re.search(r'^\d{1,4}$',major):

           minor=input('Enter minor: ')

       else:

           raise

       try:

           if re.search(r'^\d{1,4}$',minor):

               sub1=input('Enter sub1: ')

           else:

               raise

       

           try:

               if re.search(r'^\d{1,4}$',sub1):

                   sub2=input('Enter sub2: ')

               else:

                   raise

           

               try:

                   if re.search(r'^\d{1,4}$',sub2):

                       break

                   else:

                       raise

               except:

                   print('enter a correct sub 2')

           except:

               print('enter a correct sub1')        

       except:

           print('Enter a correct minor ')            

   except:

        print('enter a correct Major')

#section 2

sub1= f"{int(sub1):04d}"

sub2= f"{int(sub2):04d}"

major= f"{int(major):04d}"

minor= f"{int(minor):04d}"

if major == '0000' and minor == '0000' and sub1=='0000' and sub2=='0000':

   print('INVALID!!! Acount Number')

else:

   print('-----------------------')

   print('Your Account Number is')

   print(major, minor, sub1, sub2)

   print('-----------------------')

Explanation:

The programming language used is python 3

The Regular  Expression Module was imported to allow us perform special operations on string variables.

This is the pattern that was used to check if an input was valid or invalid re.search(r'^\d{1,4}$',string)

what this pattern does is that it ensures that:

  1. (\d) represents digits that is any number from 0-9.
  2. ( ^ ) ensures that it starts with a digit.
  3. ({1,4}) accepts digits with length ranging from 1-4. i.e you can enter at least one digit and at most four digits.
  4. ($) ensures that the input ends with a digit
  5. string is the text that is passed to the pattern

we also made use of fstrings

sub1= f"{int(sub1):04d}"

the above line of code takes 'sub1' in this case, and converts it temporarily to an integer and ensures it has a length of 4 by adding 0's in front of it to convert it to a four digit number.

These are the major though areas, but i'll explain the sections too.

#section 1

In this section the WHILE loop is used in conjunction with the TRY and EXCEPT block and the IF statement to ensure that the correct input is given.

The while loop will keep looping until the correct input is inserted  before it breaks and each input is tested in the try and except block using the if statement and the regular expression pattern I explained, as a result, you cannot input a letter, a blank space, a punctuation or numbers with length greater than 4, it has to be numbers within the range of 1-4.

#section 2

The second section converts each entry to a four digit number and checks with an if statement if the entry is all zeros (0000 0000 0000 0000) and prints invalid.

Otherwise, it prints the account number.

check the attachment to see how the script runs.

You might be interested in
Which attack intercepts communications between a web browser and the underlying computer?
Vlad [161]

The question has the below multiple choices

A. Man-In-The-Middle (MITM)
B. Man-In-The-Browser (MITB)
C. Replay
D. ARP poisoning

The answer is B

As compared to the Man-In-The-Middle attack, the Man-In-The-Browser attack intercepts communications between parties to manipulate or steal data. This attack seeks to intercept and steal or manipulate communication that exists between the browser and the underlying computer. It begins with a Trojan infecting the underlying computer and installing an extension into the web browser configuration.







6 0
2 years ago
What part of a check is the LEAST important?
Dmitriy789 [7]
The answer is

The memo line
7 0
3 years ago
Read 2 more answers
What technique involves graphical methods and nontechnical language that represent the system at various stages of development a
Mnenie [13.5K]

Answer:

The answer to this question this "modeling".

Explanation:

In this question, the answer is modeling because in system design we use System Analysis and Design(SAD). It is the most important subject in any software design like a mobile application, website, web pages, etc. In this subject, there is an important topic that is SDLC. The term SDLC stands for systems development life cycle or it is also known as the software development life cycle. It is a conceptual modeling used in project management that describes the stages involves the information for system development project. It maintenance the complete application. SDLC applied to technical and non-technical systems. In the SDLC many phases can be given as:

Requirement gathering and analysis:

In this phase, all the relevant information is collected from the customer to develop a product as their expectation.

Design:

In the design phase, the requirement gather by the software requirements specification (SRS) in a document that is used for software architecture.

Implementation or coding:

After completing the design phase we implement/coding in that section like User input validation, admin work, payment management, etc.

Testing:

In this section, we test all the things in software before hand over to the customer.

Deployment:

In this section after completing the testing successfully. it goes to the deployment section in this section production environment or User Acceptance testing is done depending on the customer expectation.

Maintenance:

In the maintenance section when the product is hand over customer and in future if any issue comes up and needs to be fixed or there is any Up-gradation is needed So it is done by the developers.

In computer science, any development is done on modules. So the answer to this question is modeling.

3 0
3 years ago
You have repaired a broken LCD panel in a laptop computer. However, when you disabled the laptop, you bent the hinge on the lid
Alex787 [66]
Yes it would take a second or todo
8 0
3 years ago
A(n) ____ uses the communication interface to request resources, and the server responds to these requests.
AlekseyPX
Computer Communication Software
I hope this helps! :)
6 0
3 years ago
Other questions:
  • A (blank) is a way for students to keep track of information during research
    7·2 answers
  • Which wireless technology has a typical transfer rate of 1 Mbps to 3 Mbps at distances up to about 10 meters?
    7·1 answer
  • Which of the following statements is false? a. Each object of a class shares one copy of the class's instance variables. b. A cl
    11·1 answer
  • What can you use with your keywords to narrow your search if you complete an internet search using a search engine and do not ge
    15·2 answers
  • Lenovo's ThinkPad laptop computers is designed in the United States, the case, keyboard, and hard drive are made in Thailand; th
    14·1 answer
  • 2.27 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as
    14·2 answers
  • Ryan is working on a document with many secotions. For each section,he wantes to have the title bolded,underlined,an blue. Which
    9·2 answers
  • What methods do phishing and spoofing scammers use? List and explain methods to protect against phishing and spoofing scams.
    14·1 answer
  • ....is an act of introducing an invention into market on business basis for profit​
    12·1 answer
  • Assume the size of an integer array is stored in $s0 and the address of the first element of the array in the memory is stored i
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!