Write a program using integers user_num and x as input, and output user_num divided by x three times.Ex: If the input is:20002Then the output is:1000 500 250Note: In Python 3, integer division discards fractions. Ex: 6 // 4 is 1 (the 0.5 is discarded).LAB ACTIVITY2.29.1: LAB: Divide by x0 / 10main.pyLoad default template...12''' Type your code here. '''

Answers

Answer 1
Answer:

Answer:

Following are the code to the given question:

user_num = int(input())#defining a variable user_num that takes input from user-end

x = int(input())#defining a variable x that takes input from user-end

for j in range(3):#defining for loop that divides the value three times

   user_num = user_num // x#dividing the value and store integer part

   print(user_num)#print value

Output:

2000

2

1000

500

250

Explanation:

In the above-given program code two-variable "user_num and x" is declared that inputs the value from the user-end and define a for loop that uses the "j" variable with the range method.

In the loop, it divides the "user_num" value with the "x" value and holds the integer part in the "user_num" variable, and prints its value.  


Related Questions

Use the AND function with appropriate arguments in cell H11 to determine if there is a force out at third base. There is a force out at third base if "Runner on 1st" and "Runner on 2nd" are both "Yes".
Write a python program to calculate and print the electric bill for Ethiopian Electricity Corporation. (consumer name meter number(mno),last month reading(Imr)and current month reading(cmr) of 50 customers and calculate the net bill amounts as follows: Number of unit(Nou)=cmr-lmr If Nou200 then bill =Nou*2 tax=bill*0.15 netbill=bill+tax Print all the details in the bill for all customers​
A majority of the people whose information was compromised are homeless; therefore there is no easy way to contact them in order to alert them of the security breach. How should Data-Time Inc. manage this breach in security
Which type of error occurred in the following lines of code? >>> print(9 / 0)Traceback (most recent call last): File " ", line 1, in 9/0ZeroDivisionError: division by zeroAnswer choices:reserved word errorlogical errorexceptionsyntax error
Password is an example of an authentication mechanisms that is based on " what an entity has".True or false?

Translate each statement into a logical expression. Then negate the expression by adding a negation operation to the beginning of the expression. Apply De Morgan's law until each negation operation applies directly to a predicate and then translate the logical expression back into English.Sample question: Some patient was given the placebo and the medication.
∃x (P(x) ∧ D(x))
Negation: ¬∃x (P(x) ∧ D(x))
Applying De Morgan's law: ∀x (¬P(x) ∨ ¬D(x))
English: Every patient was either not given the placebo or not given the medication (or both).
(a) Every patient was given the medication.
(b) Every patient was given the medication or the placebo or both.
(c) There is a patient who took the medication and had migraines.
(d) Every patient who took the placebo had migraines. (Hint: you will need to apply the conditional identity, p → q ≡ ¬p ∨ q.)

Answers

Answer:

P(x): x was given the placebo

D(x): x was given the medication

M(x): x had migraines

Explanation:

(a) Every patient was given the medication

Solution:

∀x D(x)

∀ represents for all and here it represents Every patient. D(x) represents x was given the medication.

Negation:¬∀x D(x).

This is the negation of Every patient was given the medication.

The basic formula for De- Morgan's Law in predicate logic is:

¬(P∨Q)⇔(¬P∧¬Q)

¬(P∧Q)⇔(¬P∨¬Q)

Applying De Morgan's Law:

          ∃x ¬D(x)

represents there exists some. As D(x) represents x was given the medication so negation of D(x) which is ¬D(x) shows x was not given medication. So there exists some patient who was not given the medication.

Logical expression back into English:

There was a patient who was not given the medication.

(b) Every patient was given the medication or the placebo or both.

Solution:

∀x (D(x) ∨ P(x))

∀ represents for all and here it represents Every patient. D(x) represents x was given the medication. P(x) represents  x was given the placebo. V represents Or which shows that every patient was given medication or placebo or both.

Negation: ¬∀x (D(x) ∨ P(x))

This is the negation or false statement of Every patient was given the medication or the placebo or both.

Applying De Morgan's Law:

∃x (¬D(x) ∧ ¬P(x))

represents there exists some. As D(x) represents x was given the medication so negation of D(x) which is ¬D(x) shows x was not given medication. As P(x) represents x was given the placebo so negation of P(x) which is ¬P(x) shows x was not given placebo. So there exists some patient who was neither given medication nor placebo.

Logical expression back into English:

There was a patient who was neither given the medication nor the placebo.

(c) There is a patient who took the medication and had migraines.

Solution:

∃x (D(x) ∧ M(x))

represents there exists some. D(x) represents x was given the medication. M(x) represents x had migraines.  represents and which means patient took medication AND had migraines. So the above logical expression means there exists a patient who took medication and had migraines..

Negation:

¬∃x (D(x) ∧ M(x))

This is the negation or false part of the above logical expression: There is a patient who took the medication and had migraines.

Applying De Morgan's Laws:

∀x (¬D(x) ∨ ¬M(x))

represents for all. As D(x) represents x was given the medication so negation of D(x) which is ¬D(x) shows x was not given medication. As M(x) represents x had migraines so negation of ¬M(x) shows x did not have migraines. represents that patient was not given medication or had migraines or both.

Logical expression back into English:

Every patient was not given the medication or did not have migraines or both.

(d) Every patient who took the placebo had migraines.

Solution:

∀x (P(x) → M(x))

∀ means for all. P(x) represents  x was given the placebo. M(x) represents x had migraines. So the above logical expressions represents that every patient who took the placebo had migraines.

Here we are using conditional identity which is defined as follows:

Conditional identity, p → q ≡ ¬p ∨ q.

Negation:

¬∀x (P(x) → M(x))

¬∀ means not all. P(x) implies M(x). The above expression is the negation of Every patient who took the placebo had migraines. So this negation means that Not every patient who took placebo had migraines.

Applying De Morgan's Law:

∃x (P(x) ∧ ¬M(x))

represents there exists some.  P(x) represents  x was given the placebo. ¬M(x) represents x did not have migraines. So there exists a patient who was given placebo and that patient did not have migraine.

Logical expression back into English:

There is a patient who was given the placebo and did not have migraines.

Write a program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit. The program displays Valid SSN for a correct Social Security number or Invalid SSN otherwise.

Answers

The program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit can be implemented in Python using regular expressions. The regular expression pattern for the SSN format can be used to validate the input.

Pythons code:

```python

import re

ssn_pattern = re.compile(r'^\d{3}-\d{2}-\d{4}$')

ssn = input("Enter your Social Security Number (format: ddd-dd-dddd): ")

if ssn_pattern.match(ssn):

print("Valid SSN")

else:

print("Invalid SSN")

```

In the above code, we first import the `re` module to work with regular expressions.

We then define the regular expression pattern for the SSN format as `^\d{3}-\d{2}-\d{4}$`. This pattern matches any string that starts with three digits, followed by a hyphen, then two digits, another hyphen, and finally, four digits.

We then prompt the user to enter their SSN using the `input()` function. We then check if the entered SSN matches the pattern using the `match()` function of the regular expression object `ssn_pattern`.

If the SSN matches the pattern, we print "Valid SSN". Otherwise, we print "Invalid SSN".

Know more about SSN,

brainly.com/question/31778617

#SPJ4

ssn = input("Enter a valid Social Security number: ")

dashes = 0

nums = 0

message = "Invalid SSN"

if len(ssn) == 11:

   for x in ssn:

       if x.isdigit():

           nums += 1

       elif x == "-":

           dashes += 1

if nums == 9 and dashes == 2:

   message = "Valid SSN"

print(message)

I wrote my code in python 3.8. I hope this helps!

Failing to include a complete ____ on each side of an && operator in an if statement is a common error in Java programming.a.
operator

b.
mathematical expression

c.
variable

d.
Boolean expression

Answers

Answer:

Boolean expression

Explanation:

The operator '&&' is called AND operator. it provide the output base on the Boolean value on each side of AND operator.

it has four possible values:

First Boolean is TRUE and Boolean is TRUE, then result will be TRUE.

First Boolean is TRUE and Boolean is FALSE, then result will be FALSE.

First Boolean is FALSE and Boolean is TRUE, then result will be FALSE.

First Boolean is FALSE and Boolean is FALSE, then result will be FALSE.

Therefore, the correct option is Boolean expression.

Want to.learn about computers​

Answers

Yes...I do want to learn about computer

On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above middle C key has a frequency of 440 Hz. Each subsequent key (black or white) has a frequency of 440 * rn, where n is the number of keys from that A key, and r is 2(1/12). Given an initial frequency, output that frequency and the next 3 higher key frequencies. If the input is 440, the output is: 440 493.883 523.251 554.365.Note: Include one statement to compute r = 2(1/12) using the pow function, then use r in the formula fn = f0 * rn. (You'll have three statements using that formula, different only in the value for n).

Answers

Answer:

sample output

Enter f0 = 440

440.0,466.1637615180899, 493.8833012561241,

523.2511306011974,  554.3652619537443

Explanation:

import math                                 // math library  

def RaiseToPower():                 //  RaiseToPower method

 r = math.pow(2,1/12)               //r = 2^(1/12)

f0 = float(input('Enter f0 : '))     //input from user

                                               

//a key has a frequency,sy f0

                                                                                                                                     

print(f0,end=' ')                      //Display statement

 for n in range(1,5):                //Iterate the loop up to  the next 4 higher key Hz

n = f0 * math.pow(r,n)         //calculate the fn value

print(fn,end=' ')                   //Display statement

 RaiseToPower()                //Call RaiseToPower method  

                                         

 

         

     

       

Constructing a concurrent server by spawning a process has some advantages and disadvantages compared to multithreaded servers. Discuss a few.

Answers

Answer:

The advantage and the disadvantage of the relevant query are illustrated in the explanation in the paragraph below.

Explanation:

Advantage:

  • The benefit of creating a simultaneous server through spawning a mechanism seems to be that alternative methods are shielded against everyone else, which would be very necessary whenever the extremely database manages communication services entirely.

Disadvantage:

  • The downside about creating a concurrent system through spawning a methodology seems to be that this process seems to be very expensive but using multicore processing systems should save this expense. It is also easier when using threads again for the aim of communicating between two or even more participants although we stop the kernel executing the correspondence.