Python Forum
Question about doc strings and tuple separator ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about doc strings and tuple separator ?
#1
this program should take two vectors as parameters, check if they are orthogonal and print "true"
if they are, or else print "false".
I should use docstrings too.

My code is pasted below, it runs smoothly and returns what I expect, but I am not sure how to include
docstrings in it.
I also wanted to ask, how come that when I define the dot product I am forced to write it this way (DotProduct = np.dot(V,W)) and this other way (V @ W) returns an error?

import numpy as np
from numpy import array
    
def v_vector(V):
  ##  return v /=np.linalg.norm(v)
    return (np.array(V))
def w_vector(W):
    return (np.array(W))

def test_ort(V,W):
    V=[1,0,-1]
    W=[1,sqrt(2),1]  
    DotProduct = np.dot(V,W)
    if DotProduct == 0:
        return True
    else:
        return False
  
print(test_ort(V,W))
Reply
#2
doc strings

@ is not a valid tuple item separator, you must use ,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 480 Feb-02-2024, 06:06 PM
Last Post: tester_V
  Trying to understand strings and lists of strings Konstantin23 2 757 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Printing a raw string with a folder separator at the end, duplicates the separator krulah 5 1,219 Nov-28-2022, 12:41 PM
Last Post: snippsat
  Splitting strings in list of strings jesse68 3 1,755 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  code with no tuple gets : IndexError: tuple index out of range Aggam 4 2,797 Nov-04-2020, 11:26 AM
Last Post: Aggam
  question: finding multiple strings within string djf123 4 2,955 May-16-2020, 01:00 PM
Last Post: snippsat
  Numpy savetxt, how save number with decimal separator SpongeB0B 1 3,207 May-10-2020, 01:05 PM
Last Post: ThomasL
  Finding multiple strings between the two same strings Slither 1 2,511 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  Question on Tuple SamGer 2 38,369 Jun-03-2019, 02:14 PM
Last Post: DeaD_EyE
  How to get first line of a tuple and the third item in its tuple. Need Help, Anybody? SukhmeetSingh 5 3,186 May-21-2019, 11:39 AM
Last Post: avorane

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020