33 Answered Questions for the topic String
I'm trying to understand tension. So here it goes: I'll start from the beginning. Let's assume I'm in space and can move around and apply forces. Let's say a rope is attached to a body(which is... more
When is tension constant in a rope?
Suppose we have a massless rope with pulling forces applied at each end. In which scenarios is the tension in the rope constant throughout? For example if there is a knot in the rope the tension is... more
Rope tension question?
If two ends of a rope are pulled with forces of equal magnitude and opposite direction, the tension at the center of the rope must be zero. True or false? The answer is false. I chose true though... more
Generate random numeric & alphabetic?
I'm making a random hexadecimal generator is it possible in visual basic to make a code that randomly generates number and letters together? How would you do it? I'm really lost. I'd like to... more
Choose For Random Strings In Commodore 64 BASIC?
I have this variable declarations on my program: X="MAGENTA" Y="CYAN" Z="TAN" A="KHAKI" Now what I want is to randomly choose one of these and `PRINT` it. But how to do this?
How could a cord withstand a force greater than its breaking strength?
How could a 100 N object be lowered from a roof using a cord with a breaking strength of 80 N without breaking the cord? My attempt to answer this question is that we could use a counter weight.... more
Python join: why is it string.join(list) instead of list.join(string)?
This has always confused me. It seems like this would be nicer: my_list = ["Hello", "world"] print my_list.join("-") # Produce: "Hello-world"Than this: my_list = ["Hello", "world"] ... more
Safe integer parsing in Ruby?
I have a string, say `'123'`, and I want to convert it to `123`.I know you can simply do `some_string.to_i`, but that converts `'lolipops'` to `0`, which is not the effect I have in mind. I want it... more
Why does comparing strings using either '==' or 'is' sometimes produce a different result?
I've got a Python program where two variables are set to the value `'public'`. In a conditional expression I have the comparison `var1 is var2` which fails, but if I change it to `var1 == var2` it... more
How to check whether a string contains a substring in Ruby?
I have a string variable with content as follows: varMessage = "hi/thsid/sdfhsjdf/dfjsd/sdjfsdn\ " "/my/name/is/balaji.so\ " ... more
How to parse a string of boolean logic in PHP?
I'm building a PHP class with a private member function that returns a string value such as: 'true && true || false' to a public member function. (This string is the result of some regex... more
Most elegant way to check if the string is empty in Python?
Does Python have something like an empty string variable where you can do: if myString == string.empty:Regardless, what's the most elegant way to check for empty string values? I find hard... more
Replacing some characters in a string with another character?
I have a string like <!-- language: lang-none --> AxxBCyyyDEFzzLMN I want to replace all `x` and `y` and `z` with `_` so that the output is A_BC_DEF_LMN How to do that? I know a... more
Count the number occurrences of a character in a string?
What's the simplest way to count the number of occurrences of a character in a string?e.g. count the number of times `'a'` appears in `'Mary had a little lamb'`
How to lowercase a string in Python?
Is there a way to convert a string from uppercase, or even part uppercase to lowercase? E.g. Kilometers --> kilometers.
How to split a delimited string in Ruby and convert it to an array?
I have a string `"1,2,3,4"` and I'd like to convert it into an array: [1,2,3,4]How?
Ruby capitalize every word first letter?
I need to make the first character of every word uppercase, and make the rest lowercase... manufacturer.MFA_BRAND.first.upcaseis only setting the first letter uppercase, but I need this: ALFA... more
Why does "Conversion from string "ID" to type integer is not valid" show on my program?
I'm trying to display my database on textboxes, with the help of the combobox for the ID. However, whenever I run my program, the error **"Conversion from string "ID" to type integer is not... more
Is there a way to substring a string?
Is there a way to substring a string in Python, to get a new string from the 3rd character to the end of the string?Maybe like `myString[2:end]`?If leaving the second part means 'till the end', if... more
How to read a file line-by-line into a list?
How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.
What is the most Pythonic way to pad a numeric string with zeroes to the left, i.e., so the numeric string has a specific length?
Convert bytes to a string?
I'm using this code to get standard output from an external program: >>> from subprocess import * >>> command_stdout = Popen(['ls', '-l'], stdout=PIPE).communicate()The... more
How do I trim whitespace?
Is there a Python function that will trim whitespace (spaces and tabs) from a string?Example: `\ example string\ ` → `example string`