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
dmitriy555 [2]
3 years ago
5

Write a function named last_digit that returns the last digit of an integer. For example, last_digit(3572) should return 2. It s

hould work for negative numbers as well; last_digit(-947) should return 7.
Computers and Technology
1 answer:
Vika [28.1K]3 years ago
6 0

def last_digit(num):

   num = str(num)

   return int(num[-1])

print(last_digit(-947))

I hope this helps!

You might be interested in
Construct sequence using a specified number of integers within a range. The sequence must be strictly increasing at first and th
natulia [17]

Answer:

Explanation:

The following code is written in Java. It first creates a function that takes in the three parameters to create the sequence, if the sequence is valid it returns the created sequence, otherwise it prints -1 and returns an empty array. The second function called compareSequences takes in to sequences as parameters and compares them, printing out the winner. A test case has been provided in the main method and the output can be seen in the image below.

import java.util.Arrays;

class Brainly {

   public static void main(String[] args) {

       int[] seq1 = createSequence(5, 4, 2);

       int[] seq2 = createSequence(5, 3, 3);

       System.out.println("Winner: " + Arrays.toString(compareSequences(seq1, seq2)));

   }

   public static int[] createSequence(int num, int upperEnd, int lowerEnd) {

       int[] myArray = new int[num];

       int middle = (int) Math.floor(num/2.0);

       myArray[0] = upperEnd;

       myArray[num-1] = lowerEnd;

       int currentValue = upperEnd;

       for (int i = 1; i < num-1; i++) {

           if (i <= middle) {

               myArray[i] = currentValue + 1;

               currentValue += 1;

           } else {

               myArray[i] = currentValue - 1;

               currentValue += 1;

           }

       }

       System.out.println(Arrays.toString(myArray));

       if (myArray[num-2] < lowerEnd) {

           System.out.println("-1");

           int[] empty = {};

           return empty;

       } else {

           return myArray;

       }

   }

   public static int[] compareSequences(int[] seq1, int[] seq2) {

       int lowestLength;

       if (seq1.length > seq2.length) {

           lowestLength = seq2.length;

       } else {

           lowestLength = seq1.length;

       }

       for (int i = 0; i < lowestLength; i++) {

           if (seq1[i] > seq2[i]) {

               return seq1;

           } else if (seq1[i] < seq2[i]) {

               return seq2;

           }

       }

       if (seq1.length > seq2.length) {

           return seq1;

       } else {

           return seq2;

       }

   }

}

7 0
2 years ago
An ______ search is when the buyer looks for information beyond personal knowledge to help make the buying decision, such as che
victus00 [196]

Answer: External

Explanation: External search could be explained as the additional information gathered beyond an individual's personal knowledge or experience in a bit to influence the individual's decision on a particular product or topic. This additional information could include; information sought from friends and families, online or internet research on relevant site, blogs or publications.

Therefore, a buyer who asks a friend, checking the internet or visiting a showroom or make other enquiries beyond his personal knowledge in other to make buying decision is making an external search.

6 0
2 years ago
A Uniform Resource Locator (URL) consists of three separate parts: network protocol, host, and web browser.
FrozenT [24]
That is false. are you doing it on a computer course.                                             <span />
3 0
3 years ago
Read 2 more answers
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
What makes manually cleaning data challenging?
Alexxandr [17]

Manually cleaning data is done manually which makes it challenging. This make it prone to mistakes.

6 0
3 years ago
Other questions:
  • Questions 6 - 9 Refer to the following code: public class WhatsIt { private int[] values; private double average; public WhatsIt
    7·1 answer
  • What are the People that make the goods called
    14·1 answer
  • This assignment is to read from an input file and process the data for a group of people. Your program calculates the interest a
    5·1 answer
  • Read each scenario, and then select the best wireless device for the worker’s needs. A trucker is constantly on the road. He fre
    8·2 answers
  • Why is outfitting a workspace with video games in technology development company considered a strategic use of money
    8·2 answers
  • When an organization uses cloud computing, they do not have to buy and maintain expensive hardware. Group of answer choices True
    6·1 answer
  • For this assignment, select one of the organizations with a prominent IT department from the Topic 1 assignment. Once identified
    11·1 answer
  • A local cinema allows customer to make a movie ticket reservation. A customer can be
    6·1 answer
  • Based on the following quote from Leonardo Da Vinci, what would be his definition of a fine artist? “Principles for the Developm
    11·2 answers
  • Read each of the following statements about Computer Science and explain why you think that statement is true.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!