Question

In Spyder, write a Python program (script) that has a variable num that is set to...

In Spyder, write a Python program (script) that has a variable num that is set to the value 35607. Your program is to display the last and second-last digit of the value stored in num. For example, when num contains the value 35607, your program should print the last digit of 35607 is 7 and the second last digit of 35607 is 0 respectively.

Your program should be able to work with whatever number is stored in the variable num. Test your program with num=35607 and num=6198.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def lastDigit(n) :

return(n % 10)

def secondlastDigit (n):

temp=int(n/10)

return (temp%10)

n = 98562;

print(secondlastDigit(n), end = " ")

print(lastDigit(n))

Add a comment
Know the answer?
Add Answer to:
In Spyder, write a Python program (script) that has a variable num that is set to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a python script that takes a six-digit integer from the user and separate the number...

    Write a python script that takes a six-digit integer from the user and separate the number into its individual digits. You program should then display each digit separated by a comma each. For example, if the user types in the number 654321, the script should display: 6,5,4,3,2,1 You can assume that the user enters the correct number of digits.

  • Write a python program write a function numDigits(num) which counts the digits in int num. Answer...

    Write a python program write a function numDigits(num) which counts the digits in int num. Answer code is given in the Answer tab (and starting code), which converts num to a str, then uses the len() function to count and return the number of digits. Note that this does NOT work correctly for num < 0. (Try it and see.) Fix this in two different ways, by creating new functions numDigits2(num) and numDigits3(num) that each return the correct number of...

  • in python 3 1. A program contains the following function definition: def cube(num): return num *...

    in python 3 1. A program contains the following function definition: def cube(num): return num * num * num Write a statement that passes the value 4 to this function and assign its return value to the variable result. 2. Write a function named get_first_name that asks the user to enter his or her first name and returns it.

  • Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a...

    Python Language Only!!!! Python Language Only!!!! Python Language Only!!!! Python 3 is used. A. Write a function named smaller that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all numbers in the list that are smaller than the number n. Write a code that declares and initializes a list of numbers and a variable number and pass them to the function to test it. Please see the outcome below:...

  • Swapping Values in python Summary In this lab, you complete a Python program that swaps values...

    Swapping Values in python Summary In this lab, you complete a Python program that swaps values stored in three variables and determines maximum and minimum values. The Python file provided for this lab contains the necessary input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate....

  • hi, please use spyder formatting or python 3 accessible Apps M Gmail Maps YouTube Python 3...

    hi, please use spyder formatting or python 3 accessible Apps M Gmail Maps YouTube Python 3 1h 51m left 1. Multiplying with a Sentinel and Branching Negative ALL Write a program that will calculate the product of user-specified negative numbers, in succession, until the user enters done. And then display the final product. Zero is considered positive and the initial product should set to 1. Here is an example run of the program: Enter a number or done to quit:...

  • Write a Python script that allows a user to input three exam scores. Display a congratulatory...

    Write a Python script that allows a user to input three exam scores. Display a congratulatory message if the average exam score across all three is greater than 95%. Your solution should follow these general steps; Obtain the first exam score from the user in the form score/max Example: 93/100 Obtain the second score Obtain the third score Check that the user provided numbers and compute the average test score Display the average If the average was greater than 95%,...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

  • 1. Write the command to set the following permissions on a script file with the following...

    1. Write the command to set the following permissions on a script file with the following name; myscript.sh Owner: full access; read, write and execute Group: read and execute Other: no access 2. Create a new file with the name "myfirstscript.sh". Write a new script that performs the following tasks in sequence; Display the usernames of currently logged in users; sorted from a-z HINT: You will need to filter the output of the whocommand Display a list of usernames who...

  • a c++ program: For this project you will write a program to add very large (unsigned)...

    a c++ program: For this project you will write a program to add very large (unsigned) integers. The two summands should be stored arrays, one array for each summand. The summands should be stored with one digit per location in the two arrays. Your program should, starting at the least significant digits compute the sum by adding the two integers digit by digit. Do not forget to handle carries. Your program should be able to handle summands with up to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT