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
A central issue of public sharing is:
Troyanec [42]
I think is b.how much time we spend alone
6 0
2 years ago
Read 2 more answers
48
Irina-Kira [14]

The statement that best explains the benefit that higher page placement provides those who use search engine optimization well is option A. People are more likely to click the first results than those further down the page.

<h3>What advantages do search engine results pages offer?</h3>

Search engine results pages (SERPs) typically feature paid search and pay-per-click (PPC) advertisements in addition to organic search results. Since consumers are more inclined to click on results at the top of the page, ranking position on a SERP can be very competitive thanks to search engine optimization (SEO).

Therefore, Search engine optimization, or SEO, is the act of enhancing your website to raise its natural prominence for particular search queries. Through onsite adjustments, SEO seeks to increase both the quality and volume of traffic to your website.

Learn more about search engine optimization from

brainly.com/question/14097391
#SPJ1

3 0
1 year ago
Why is it important to respect other political opinions
steposvetlana [31]

It is important to respect other political opinios because America is a free country. Hearing others opinios are also important in life, because it helps us see the world in different persective.

6 0
3 years ago
Read 2 more answers
If data from a DOS system is electronically sent to an EHR or other Windows-based system via an interface to populate an indexed
ra1l [238]

Answer:

yes ! you can see below.

Explanation:

EHR is a health record of a patient that gives information about the patient and securely authorized it. Electronic Health record allows medical professionals to enter data and update a new encounter.

DOC is a document used by Microsoft. DOC file is a file that contains formatted text, images, tables, graphs, and charts, etc.

Unstructured data is data that can be entered in free text format. Structured information is a type of data contain check boxes, images table, and other the user chooses from the given option.

As the DOC system contain free text format, then data in the EHR is structured.

8 0
3 years ago
You are holding a rock tied to a string, which is an example of a pendulum. identify and explain the proper term for each part o
erik [133]

Your hand is the pivot or the fulcrum. It is where the pendulum swings from. The string is the lever; it holds the weight and undergoes tension forces. The stone is the load. It can be put to some certain height and cause the swinging.

<span />
3 0
3 years ago
Read 2 more answers
Other questions:
  • You should hand write your references on your resume.
    15·2 answers
  • Framing can create which of the following in a photograph? Mystery Saturation Aperture All of the above
    10·2 answers
  • Write a function to add two large integers of any length, say up to 200 digits. A suggested approach is as follows: treat each n
    12·1 answer
  • ________ applications are software in which the vendor hosts the software online over the Internet and you do not to install the
    15·1 answer
  • What is one of the first power tools you’ll need as electrician
    15·1 answer
  • Discuss two business information systems that are used in two different sectors in a modern economy.
    11·1 answer
  • Consumer consequences for illegally downloading software
    6·1 answer
  • What is the first things u do upon seeing this sheet?​
    14·2 answers
  • Place the steps for attaching a file to a message in order from top to bottom.
    12·1 answer
  • A corporation is looking to receive approval from its shareholders. The corporation needs to communicate financial information a
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!