No overload for method 'Given' takes 4 arguments - specflow - nuget

I have installed specflow. And by default I get this scenario to add two numbers. when I build the solution, i get these errors. "No overload for method 'Given' takes 4 arguments". What is that I am missing here? this is the generated file.
public virtual void AddTwoNumbers()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add two numbers", new string[] {
"mytag"});
#line 7
this.ScenarioSetup(scenarioInfo);
#line 8
testRunner.Given("I have entered 50 into the calculator", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 9
testRunner.And("I have entered 70 into the calculator", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 10
testRunner.When("I press add", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
testRunner.Then("the result should be 120 on the screen", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}
For this scenario:
Feature: SpecFlowFeature1
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
#mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen

It was a problem of techtalk.specflow.dll version. I had 1.8.1 version which I replaced with 1.9.0 and everything worked ! Thank u for ur suggestions

Related

To extract numbers after a particular string

I want to extract a number that follows a specific string ':' and write a code that adds that number. I think.. can split it by space and extract it from it... Well, it doesn't work.
1.(12321 6,80.0:3 210.1:3!!!73 540.2:1++ 96.3:3!<<<<%% 689.4:3 24.5:4)
I want to extract the number 3 3 1 3 3 3 4 followed by ":" from this string and find out that the sum is 17.
import re
var1 = '1.(12321 6,80.0:3 210.1:3!!!73 540.2:1++ 96.3:3!<<<<%% 689.4:3 24.5:4)'
item = var1.split(" ")
sum([int(i) for i in re.findall('(?<=:)\\d+',var1)])
17

Finding the three longest substrings in a string using SPARQL on the Wikidata Query Service, and ranking them across strings

I'm trying to identify the longest three substrings from a string using SPARQL and the Wikidata Query Service and then rank
the substrings within a string by length
the strings by the lengths of any of those longest substrings .
I managed to identify the first and second substring from a string and could of course just create similar additional lines to tackle the problem, but this seems ugly and inefficient, so I am wondering if anyone here knows of a better way to get there.
This is a simplified version of the code, though I have left some auxiliary variables in that I am using for tracking progress on the way. You can try it here.
Clarification in response to this comment: if it is necessary to treat this query as a subquery and to feed it with results from another subquery, that's fine with me. To get an idea of the kinds of use I have in mind, see this demo.
SELECT * WHERE {
{
VALUES (?title) {
("What are the longest three words in this string?")
("A really complicated title")
("OneWordTitleInCamelCase")
("Thanks for your help!")
}
}
BIND(STRLEN(REPLACE(?title, " ", "")) AS ?titlelength)
BIND(STRBEFORE(?title, " ") AS ?substring1)
BIND(STRLEN(REPLACE(?substring1, " ", "")) AS ?substring1length)
BIND(STRAFTER(?title, " ") AS ?postfix)
BIND(STRLEN(REPLACE(?postfix, " ", "")) AS ?postfixlength)
BIND(STRBEFORE(?postfix, " ") AS ?substring2)
BIND(STRLEN(REPLACE(?substring2, " ", "")) AS ?substring2length)
}
ORDER BY DESC(?substring1length)
Expected results:
longsubstring substringlength
OneWordTitleInCamelCase 23
complicated 11
longest 7
really 6
string 6
Thanks 6
title 5
three 5
your 4
help 4
Actual results:
title titlelength substring1 substring1length postfix postfixlength substring2 substring2length
Thanks for your help! 18 Thanks 6 for your help! 12 for 3
What are the longest three words in this string? 40 What 4 are the longest three words in this string? 36 are 3
A really complicated title 23 A 1 really complicated title 22 really 6
OneWordTitleInCamelCase 23 0 0 0

How do I fix Unbound Local Error in Python 3

im doing a homework assignment for one of my classes EMT 1111 and Im stuck on this situation at the moment. The question that im trying to answer ask me this question: Write an interactive console program that prompts the user to read in two input values: a number of feet, followed on a separate line by a number of inches. The program should convert this amount to centimeters. Here is a sample run of the program (user input is shown like this):
This program converts feet and inches to centimeters.
Enter number of feet: 5
Enter number of inches: 11
5 ft 11 in = 180.34 cm
Here the coding that I had done so far for this program assignment
centimeters = 2.54
feet_to_inches = feet * 12
print("This program converts feet and inches to centimeters.")
feet = int(input("Enter number of feet: "))
inches = int(input("Enter number of inches: "))
inches_to_centimeters = (feet_to_inches + inches) * centimeters
print = float(input(feet, "ft", inches, "in =",inches_to_centimeters, "cm"))
Every time I keep submitting the code I keep getting an unbound local error. Can someone point the mistake im making so I can fix it
I’m not sure if it’s the reason for the error, but in your last line you use print as a variable name. print is a keyword in python, so you can’t use it as a variable name.
You have a number of issues:
On your 2nd line, you are using feet before it is defined.
On your 9th line, you are using print as a variable instead of a function.
Also on your 9th line, you have what should be printed wrapped in an input function
It's minor, but I would suggest self-descriptive variable names.
So with this in mind, let's refactor your code:
#!/usr/bin/env python3.7
It's a good idea to include a shebang line to make sure you target the correct Python version.
feet_to_inches_multiplier = 12
inches_to_centimeters_multiplier = 2.54
As I said, use self descriptive variables. This way it is more obvious what their intended purpose is.
print("This program converts feet and inches to centimeters.")
This line is fine.
feet = int(input("Enter number of feet: "))
inches = int(input("Enter number of inches: "))
centimeters = (feet * feet_to_inches_multiplier) * inches_to_centimeters_multiplier
Hopefully, you can see the increase in readability here and how the centimeters calculation flows naturally.
print(feet, "ft", inches, "in =", centimeters, "cm")
And this, I assume, is supposed to be a simple print statement.
Here's the output:
This program converts feet and inches to centimeters.
Enter number of feet: 1
Enter number of inches: 1
1 ft 1 in = 30.48 cm
I don't really understand what you want to do but, print() doesn't support the way you're trying to pass those arguments.
For the piece of code provided, the following code may be what you're looking for:
centimeters = 2.54
print("This program converts feet and inches to centimeters.")
feet = int(input("Enter number of feet: "))
feet_to_inches = feet * 12
inches = int(input("Enter number of inches: "))
inches_to_centimeters = (feet_to_inches + inches) * centimeters
print(feet, "ft", inches, "in =", inches_to_centimeters, "cm")
Hope this help you.

Why are my printed outputs different?

I've been slowly building up skillsets in Swift. Drawing with loops is a great way I find, to understand the subtleties of the language.
Here is an interesting puzzle I can't quite figure out:
I've been trying to generate a truncated pyramid like this for a little while.
I finally got a rough one produced using a for loop. screenshot here BUT, as you can see, one of my earlier attempts generated a half truncated pyramid.
The only difference between the two is that on lines 19 and 33, the variable "negativeSpaceThree" is diminished by 2 and 1 respectively.
Can anyone explain why the outputs are so different? I'd really like to understand these nuances. It might simply be my math, but I'm wondering if its a bug.
Many thanks for any input offered.
Code added below:
let space = " "
var negativeSpaceTwo = 22
var xTwo = 3
for circumTwo in 1...11{
xTwo += 2
negativeSpaceTwo -= 2
print(String(repeating: "-", count: negativeSpaceTwo) , String(repeating:"*", count: xTwo ))
}
print(space)
print(space)
var negativeSpaceThree = 11
var xThree = 3
for circumTwo in 1...11{
xThree += 2
negativeSpaceThree -= 1
print(String(repeating: "-", count: negativeSpaceThree) , String(repeating:"*", count: xThree ))
}
It's because of the difference in how many * characters you are printing on each line. If your total line length is total = dashes + stars and you subtract 2 from dashes each time while adding 2 to stars each time, the total line length will remain the same.
In the second pyramid, you reduce the dashes by one, but add 2 to stars, so the total length increases by 1 each line, giving the pyramid effect on the right-hand side of the text.

Why does Swift playground shows wrong number of executions?

I am using a completion handler to sum up numbers. What I don't understand is if I break my code in 2 lines, the number of executions would change from 6 to 7!! WHY?
func summer (from : Int, to: Int, handler: (Int) -> (Int)) -> Int {
var sum = 0
for i in from...to {
sum += handler(i)
}
return sum
}
summer(1, to:6){ //Shows '21'
return $0} // shows '(6 times)'
// Same code, but in 1 line
summer(1, to:6){return $0} // shows '(7 times)'
IMAGE
It's showing how many times a function / expression is being called on that line:
since the calling expression (summer()) is on the same line, it counts as an extra operation. Hence, 6 prints + 6 returns + 1 summer() = 13 times something happened on that line.
I'm sure I'm not using the correct terminology, but this is what's going on.
It's merely a consequence of the presentation:
21 //the result from the first time
(6 times) //the other 6 times
(7times) //all 7 times, including the 21 one.