Question

How to break a while loop in a keyboard interrupt in python? The simplest without doing...

How to break a while loop in a keyboard interrupt in python? The simplest without doing much of an import from a library

Homework Answers

Answer #1

The python program is given below.

while(1):

      print "1"

=>This will go in an infinite loop every time it prints 1.

=>In order to break this while loop you've to press Ctrl+c.

=>It'll stop the infinite loop i.e., printing 1.

=>In the below image you can observe "keyboardInterrupt" after pressing Ctrl+c.

Know the answer?
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
Similar Questions
USING PYTHON do all the he problems using while loop , continue and break 1-This problem...
USING PYTHON do all the he problems using while loop , continue and break 1-This problem provides practice using a while True loop.write a function named twoWords that gets and returns two words from a user. The first word is of a specified length, and the second word begins with a specified letter.The function twoWords takes two parameters: an integer, length, that is the length of the first word and a character, firstLetter, that is the first letter of the...
This is an exercise using a while loop Input an integer n from the keyboard. Calculate...
This is an exercise using a while loop Input an integer n from the keyboard. Calculate the sum of the first n integers. So if n=10, the answer should be 55 (because 1+2+3+4+5+6+7+8+9+10=55) Code language: Java
1) In Python Use a while loop to ask the user to enter a series of...
1) In Python Use a while loop to ask the user to enter a series of alphabets. The loop terminates when the user presses enter. Once the loop terminates, display the number of vowels and consonants entered by the user. Hint: keep a running count of the number of characters entered by the user. Keep a running count of the number of vowels. Total number of consonants = total number of characters - total number of vowels. Assume that the...
Write a python while loop that sums all the numbers from m to n, where “m”...
Write a python while loop that sums all the numbers from m to n, where “m” and “n” are both user given values.
how to calculate standard deviation in python without any packages and functions except len(). And ensure...
how to calculate standard deviation in python without any packages and functions except len(). And ensure the outcome is same as the output from r function sd().
Python Albert Einstein famously said that compound interest is the 8th wonder of the world. Hopefully,...
Python Albert Einstein famously said that compound interest is the 8th wonder of the world. Hopefully, all of you have had a finance course to teach you why it is so much more powerful than simple interest, which we programmed in class. If you are unfamiliar with compound interest, google it (note - if you google "compound interest for dummies" you will get a MUCH simpler explanation of how it works, without greek function notations!!) Your assignment this week is...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using...
Please do it in Python Write the simplest program that will demonstrate iteration vs recursion using the following guidelines - Write two primary helper functions - one iterative (IsArrayPrimeIter) and one recursive (IsArrayPrimeRecur) - each of which Take the array and its size as input params and return a bool. Print out a message "Entering <function_name>" as the first statement of each function. Perform the code to test whether every element of the array is a Prime number. Print out...
Writing a program in Python that reads a text file and organizes the words in the...
Writing a program in Python that reads a text file and organizes the words in the file into a list without repeating words and in all lowercase. Here is what I have #This program takes a user input file name and returns each word in a list #and how many different words are in the program. while True:   #While loop to loop program     words = 0     #list1 = ['Programmers','add','an','operating','system','and','set','of','applications','to','the','hardware',          # 'we','end','up','with','a','Personal','Digital','Assistant','that','is','quite','helpful','capable',           #'helping','us','do','many','different','things']        try:        ...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number...
Use Python 3.8: Problem Description Many recipes tend to be rather small, producing the fewest number of servings that are really possible with the included ingredients. Sometimes one will want to be able to scale those recipes upwards for serving larger groups. This program's task is to determine how much of each ingredient in a recipe will be required for a target party size. The first inputs to the program will be the recipe itself. Here is an example recipe...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT