Answer:
number = int(input("Enter a number: "))
if number % 2 == 0:
print("Even")
else:
print("Odd")
Explanation:
Currently taking python at school. On the last few lessons.
Building a String Library
Sometimes when programming you need to introduce a new data type and develop a library of functions for manipulating instances of that data type. Often this is done as methods on a new class but not always.
In this assignment, you'll be defining a collection of functions on strings, most of which already exist as methods on the str class. However, you should pretend that they don't already exist and define them as functions. Of course, you can't just use the existing methods. This will give you a bunch of practice on manipulating strings and also on defining functions.
In this assignment, you'll be defining a collection of functions on strings. You should define each of these as a new function with a function header as below. The description of each is in the comment supplied. Recall that strings are immutable, so you will have to return a new copy of the string for those that call for you to return a string. If you are returning the same string as the input, just return it; there is no need to make a new copy, and it wouldn't anyway.
The only string functions/methods to use:
ord, chr
indexing and slicing
append (i.e., ``+'')
len, in, not in
equality comparison (== or !=))
Looping over strings (while or for loops) and selection (if statements) are allowed. BUT You cannot convert the strings to other types such as lists.
Define each of the following functions, with semantics as indicated by the comment. In each of the following ch is a single character, str, str1, str2 are strings, and i is a non-negative integer. You do not have to validate the inputs, except as indicated; you can assume these types.
At least one question asks you to return two values. That really means returning a tuple (pair) of values. You do that as follows:
return value1, value2
This actually returns the pair (value1, value2). The caller can then assign the members of the pair to two variables:
x, y = pairReturningFunction() # assumes function returns a pair
z, w = (value1, value2) # assigning a tuple to 2 variables
If you like, you can use earlier functions in later ones, or define helper functions, though it shouldn't really be necessary. Note that some of these are trivial to write, while others are a bit harder. I have done the first one for you.
def myAppend( str, ch ):
# Return a new string that is like str but with
# character ch added at the end
return str + ch
def myCount( str, ch ):
# Return the number of times character ch appears
# in str.
def myExtend( str1, str2 ):
# Return a new string that contains the elements of
# str1 followed by the elements of str2, in the same
# order they appear in str2.
def myMin( str ):
# Return the character in str with the lowest ASCII code.
# If str is empty, print "Empty string: no min value"
# and return None.
def myInsert( str, i, ch ):
# Return a new string like str except that ch has been
# inserted at the ith position. I.e., the string is now
# one character longer than before. Print "Invalid index" if
# i is greater than the length of str and return None.
def myPop( str, i ):
# Return two results:
# 1. a new string that is like str but with the ith
# element removed;
# 2. the value that was removed.
# Print "Invalid index" if i is greater than or
# equal to len(str), and return str unchanged and None
def myFind( str, ch ):
# Return the index of the first (leftmost) occurrence of
# ch in str, if any. Return -1 if ch does not occur in str.
def myRFind( str, ch ):
# Return the index of the last (rightmost) occurrence of
# ch in str, if any. Return -1 if ch does not occur in str.
def myRemove( str, ch ):
# Return a new string with the first occurrence of ch
# removed. If there is none, return str.
def myRemoveAll( str, ch ):
# Return a new string with all occurrences of ch.
# removed. If there are none, return str.
def myReverse( str ):
# Return a new string like str but with the characters
# in the reverse order.
Expected output:
>>> from MyStringFunctions import *
>>> s1 = "abcd"
>>> s2 = "efgh"
>>> myAppend( s1, "e" )
'abcde'
>>> myCount( s1, "e")
0
>>> myCount( s1, "a")
1
>>> myCount( "abcabc", "a")
2
>>> myExtend( s1, s2 )
'abcdefgh'
>>> myMin( "" )
Empty string: no min value # Note the None doesn't print
>>> myMin( "zqralm" )
'a'
>>> myMin( "Hello World!" )
' '
>>> myInsert( "abc", 0, "d")
'dabc'
>>> myInsert( "abc", 2, "d")
'abdc'
>>> myInsert( "abc", 4, "d")
Invalid index # Note the None doesn't print
>>> myPop( "abcd", 1 )
('acd', 'b')
>>> myPop( "abcd", 0 )
('bcd', 'a')
>>> myPop( "abcd", 5)
Invalid index
('abcd', None)
>>> myFind( "abcdabcd", "a")
0
>>> myFind( "abcdabcd", "c")
2
>>> myFind( "abcdabcd", "f")
-1
>>> myRFind("abcdabcd", "d")
7
>>> myRFind("abcdabcd", "e")
-1
>>> myRemove( "abcdabcd", "a")
'bcdabcd'
>>> myRemove( "abcdabcd", "x")
'abcdabcd'
>>> myRemove( "abcdabcd", "d")
'abcabcd'
>>> myRemoveAll("abcabcabca", "a")
'bcbcbc'
>>> myReverse( "abcd" )
'dcba'
>>> myReverse( "" )
''
examples of ownership
Answer:
Ownership is the legal right to possess something. An example of ownership is possessing a specific house and property. The total body of rights to use and enjoy a property, to pass it on to someone else as an inheritance, or to convey it by sale.
Type the correct answer in each box. Spell all words correctly, and use numerals instead of words for numbers. If necessary, use / for the fraction bar(s). What is the hexadecimal equivalent of the decimal number 125.28? The hexadecimal equivalent of the decimal number 125.28 is
Answer:
125.28₁₀ in hexadecimal = 7D.47AE147AE1₁₆
Step-by-Step Explanation:
To convert decimal number 125.28, we convert its integer and fraction part individually and then add them to get the equivalent hexadecimal number, as below:
To convert integer 125 to hexadecimal, follow these steps:
Divide 125 by 16 keeping notice of the quotient and the remainder. Continue dividing the quotient by 2 until you get a quotient of zero.
Then just write out the remainders in the reverse order to get the equivalent hexadecimal number.
125 / 16 = 7 with remainder 13 (D)
7 / 16 = 0 with remainder 7
Here is the answer to 125 decimal to hexadecimal number:
7D
For converting decimal fraction 0.28 to hexadecimal number, follow these steps:
Multiply 0.28 by 16 keeping notice of the resulting integer and fractional part. Continue multiplying by 16 until you get a resulting fractional part equal to zero (we calcuclate upto ten digits).
Then just write out the integer parts from the results of each multiplication to get equivalent hexadecimal number.
0.28 × 16 = 4 + 0.48
0.48 × 16 = 7 + 0.68000000000001
0.68000000000001 × 16 = 10 (A) + 0.88000000000011
0.88000000000011 × 16 = 14 (E) + 0.080000000001746
0.080000000001746 × 16 = 1 + 0.28000000002794
0.28000000002794 × 16 = 4 + 0.48000000044703
0.48000000044703 × 16 = 7 + 0.68000000715256
0.68000000715256 × 16 = 10 (A) + 0.88000011444092
0.88000011444092 × 16 = 14 (E) + 0.080001831054688
0.080001831054688 × 16 = 1 + 0.280029296875
Here is the answer to 0.28 decimal to hexadecimal number:
0.47AE147AE1
Therefore, decimal number 125.28 converted to hexadecimal is equal:
7D.47AE147AE1
You are given an integer N where 0 <= N <= 100, followed by another line of input which has a word W with length L where 1 <= L <= 50. Your task is to print N lines with the word W. The lines of your output should not have any trailing or leading spaces.
Your output lines should not have any trailing or leading whitespaces
Input
3
Hello
Output
Hello
Hello
Hello
import math as m
def print_word(N, W, retries = 4):
for _ in retries:
if(N > 100 or N < 0 or len(W) > 50):
print("Number is out of range or word is too large. Try again.")
new_word = str(input("New word: "))
new_num = int(input("New number: "))
if(new_num >= 0 and new_num <= 100 and len(W) <= 50):
for row in new_num:
print(new_word)
return "Thank you for your time!"
if(N >= 0 and N <= 100 and len(W) <= 50):
for row in N:
print(W)
return "Thank you for your time!"
try:
N = m.floor(int(input("Enter a number from 0 to 100: " )))
W = str(input("Enter a word: "))
except ValueError:
print("Invalid Input!")
print(print_word(N,W))
Following are the python program to print the input string value:
Program:N= int(input("Enter a value of integer N (0 <= N <= 100): "))#defining an integer variable N that inputs integer value from the user-end
W = input("Enter the word W (length of 1 <= L <= 50): ")#defining a string variable W that inputs the value fom the user-end
for n in range(N):#defining a for loop that uses the range method with integer variable and prints the string value
print(W)#printing the string value
Program Explanation:
Defining the an integer variable "N" that inputs an integer value from the user-end.In the next step, another variable "W" is declared that inputs the string value from the user-end.After input all the value a for loop is declared that uses the range method with integer variable and prints the string value.Output:
Please find the attached file.
Fin out more information about the program here:
brainly.com/question/24604692
Tumblr, Jaiku is an example of _____________ website.
a) Microblogging
b) Blogging
c) Social Networking
d) None of the Above
Answer:
Microblogging One of the best-known channels in the microblogging world. Twitter is a quick and convenient way to share short posts, GIFs, article links, videos and more. Pinterest: Companies on Pinterest link to products, articles and other useful information for audiences .Explanation:
Hope this helps you !! Sarah is a detall-oriented programmer. While testing her program, what other skill would she have to apply in order to detect all bugs?
What’s the relationship among speed frequency and the number of poles in a three phase induction motor
Answer:
The number of poles in the windings defines the motor's ideal speed. A motor with a higher number of poles will have a slower rated speed but a higher rated torque.
Explanation:
The relationship among speed, frequency, and the number of poles in a three-phase induction motor is governed by what is known as the synchronous speed equation.
The synchronous speed of an induction motor is the speed at which the rotating magnetic field generated by the stator windings of the motor rotates.
The synchronous speed (Ns) of a three-phase induction motor is given by the following equation:
Ns = (120 × f) / P
where:
Ns is the synchronous speed in revolutions per minute (RPM).
f is the supply frequency in hertz (Hz).
P is the number of poles.
From the equation, it can be observed that the synchronous speed is directly proportional to the frequency and inversely proportional to the number of poles.
This means that if the frequency increases, the synchronous speed also increases, assuming the number of poles remains constant.
Conversely, if the frequency decreases, the synchronous speed decreases.
The actual speed of an induction motor is known as the rotor speed or slip speed, which is always slightly lower than the synchronous speed. The difference between the synchronous speed and the actual speed is referred to as slip and is necessary for the motor to induce a voltage in the rotor and generate torque.
It's important to note that the synchronous speed equation assumes an ideal motor with no load. In practice, the actual speed of the motor depends on various factors, including the load torque, rotor resistance, and motor design.
Learn more about synchronous speed equation click;
https://brainly.com/question/33166801
#SPJ2
Convert 12 bits to bytes
Answer:
1.5 bytes
Explanation:
I byte = 8 bit ....
__________ can collect information about credit card numbers.
a) Spyware
b) Virus
c)Trojan Horse
d) Worm
Answer:
SpywareSpyware collects your personal information and passes it on to interested third parties without your knowledge or consent. Spyware is also known for installing Trojan viruses. Adware displays pop-up advertisements when you are online.Explanation:
Hope this helps !!how is integrating approach in done in teaching
Answer: Integrative learning is an approach where the learner brings together prior knowledge and experiences to support new knowledge and experiences.
Explanation:
Research.
Does The ps5 digital have a disc drive even Though ps4 games are not compatible
Answer:
Since the PS5 is backward compatible with the PS4, PS4 games can be played on the new console. Then, select the game hub from your Games home page. Quick tip: If you have a PS5 Digital Edition, you won't be able to use physical game discs since it does not have a disc drive to read them.
Explanation:
HOPE IT HELPS
Briefly explain the Conleptual model 044
effective computer Based instruction
for adult outlining the three units
(output, process, input)
According to computer analysis, the concept of effective computer-based instruction for adults is the embedment of the fundamental parts of computer-based instruction to provide the expected stratagems for inquiry in CBI for adults.
The three (3) units output, process, and input
Output in CBI External supportCBI DesignInstructional Strategy designProcess in CBISelf DirectednessComputer Self EfficacyLearning Goal LevelOutput in CBILearning OutcomeScreen DesignPractice StrategyHence, in this case, it is concluded that computer-based instructions can be effective for adult learning.
Learn more about Computer Based Instructions here: brainly.com/question/15697793
Role and responsibility of an IT professional
Type the correct answer in the box
How is it possible to understand the flow of data in an organization?
Conducting ______ with each team member makes it possible to understand the flow of data in an organization.
Why is information so important in our lives
Which cloud computing model allows users to create their own applications given a specific set of tools
I believe Windows or Apple computers. Sorry if I’m not helpful.
See if you can do better then I did
Answer:
no i can't do better ggs
Explanation:
im not smart (also I did answer the question ;) )
Does technology always follow the science,yes or no explain why to choice
Answer:
NoExplanation:
because Technology does not always follow science but it may actually lead science in some instances. An example is weather forecasting.Again Mark me brainliest plz i really need itTrue or false: the web-based game "We Are Data" connected to real data in real time in the cities of London, Berlin, and Tokyo.
The web-based game we data is connected to real data in the real-time of cities such as London and berlin is true.
What is a web-based game?The web-based game is one that is an online internet-based game that makes use of the browser and is a multiplayer game this can be connected to the server of the host or the home country such as the berline, Toyko, and even London, etc.
Find out more information about the web-based game.
brainly.com/question/21133985
What is accomplished by the following code snippet, assuming all variables had been
populated?
amount_owed += duration rate
O Amount owed is set to duration times rate.
O Amount owed adds duration times rate to it.
O Amount owed is displayed to a user as duration rate.
O This line would return a syntax error.
There are different kinds of computer programs. The option that is accomplished by the following code snippet is the Amount owed adds duration times rate to it.
Code Snippet is simply regarded as a term used to show a tiny portion of re-usable source code, machine code etc. It is know to help a programmer to avoid typing repetitive code when undergoing routine programming.It is a common example in documentation. It depicts how to use some particular class or how to finish an assigned task. It can be in form of a short snippet that is based on a specific task or a longer one.
Learn more about Code Snippet from
https://brainly.com/question/24171161
Which of the following is not an Error Style for data validation?
Based on the Microsoft Excel data validation, the option that is not an Error Style for data validation is the choice that does not show an error alert.
Given that there is no option available, the best way to answer this question is to show the types of Error Styles for data validation available.
Different types of Error Style for data validationStop style: this will bring the option of "Retry, " "Cancel, " and "Help."Warning style: this will show "Continue," with options of "Yes," "No," "Cancel," and "Help."Information Style: this will ask you to input the whole number with the option of "Ok," "Cancel," and "Help."Hence, in this case, it is concluded that the Error Style for data validation is Stop, Warning, and Information Style.
Learn more about Error Style for data validation here: https://brainly.com/question/18497347
conclusion for project for computer
OK this question is answer easy the computer important of future
Explain in detail what it means to synchronize computers and mobile devices and include at least two strategies for keeping your files in sync in your answers
Answer:
Explanation:
To synchronize computers and mobile devices means to use a cloud service that constantly checks to see if local files are up-to-date with the files in the cloud. These services update the cloud files with the local files if they are overwritten for maximum convenience.
Two strategies for keeping files in sync are using Dropbox. Another way is using iCloud if one has Mac/iOS devices.
What is the new programming language for developing iOS and Mac app
Answer:
Swift
Explanation:
I'm not sure about new, but IOS developers have been using Swift ever since the begining of time!
What sound customization option would you use in Scratch to simulate a sound happening in a large, empty room (like a theater)?
louder
reverse
echo
slower
Answer:
Louder
Explanation:
what changes might you make to a circuit in order to slow the flow of electrical energy?
Answer: The resistor uses the energy of the electrons around the wire and slows down the flow of electrons.
Explanation:
g Tonya recognizes that one example of the impact of censorship on Internet service providers (ISPs) is that
Which part of the computer is responsible for managing memory allocation for all applications
A. Word processor
B. Operating system
C. Web browser
D. Intergrated development environment
I think it’s B but I’m not sure so I want to see if I’m right before answering
Answer:
Option B
Explanation:
The operating system is the type of software that is responsible for managing the processor time and also the memory allocation in the system. The operating system mainldeals with the processor time by scheduling the processor work done in the system.
The OS mainly controls the system and then schedule the execution of various types of function by the central processing unit (CPU). It also controls the memory allocation in the system.
The part of the computer responsible for managing memory allocation for all applications is the operating system. The correct option is B.
What is an operating system?The operating system is the kind of software in charge of controlling the system's memory allocation and CPU usage. By scheduling the system's processor work, the operating system primarily manages processor time.
The operating system (OS) primarily manages the system and schedules the central processor unit's performance of many types of functions. Additionally, it manages the system's memory allocation.
The CPU is the brain of the computer. It manages all the functions of the computer. It is a small rectangle chip-like structure present inside the box with other parts.
Thus, the part of the computer that is responsible for managing memory is the operating system. The correct option is B.
To learn more about the operating system, refer to the link:
https://brainly.com/question/6689423
#SPJ2
A data analyst is working with a data frame named retail. It has separate columns for dollars (price_dollars) and cents (price_cents). The analyst wants to combine the two columns into a single column named price, with the dollars and cents separated by a decimal point. For example, if the value in the price_dollars column is 10, and the value in the price_cents column is 50, the value in the price column will be 10.50. What code chunk lets the analyst create the price column
The code chunk that lets the analyst create the price column is;
unite(retail, “price”, price_dollars, price_cents, sep=”.”)
The code chunk unite(retail, “price”, price_dollars, price_cents, sep=”.”) is the one that will allow the analyst to create the price column.
The reason for that answer is that;
The unite() function would allow the analyst to make the dollars and cents data to be combined into a single column.Meanwhile, in the parentheses of the given function, the analyst will write the name of the data frame.Next step for the analyst is to write the name of the new column in quotation marks.Next step is the names of the two columns they want to combine.Lastly, the argument sep=”.” will now place a decimal point between the dollars and cents data given in the price column.Read more about programming at; https://brainly.com/question/15683939
Which of the four factors of production are hit the hardest when high unemployment occurs ?
Answer:
Economic growth,cyclical and structural factors, demographics, education and training
Explanation:
.........