Python Forum
could someone explain keywords, marks, and function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
could someone explain keywords, marks, and function
#1
Dear everyone,

I just started to study Python. I still need to grasp some basic concepts. If someone helps with these, I appreciate:

1- Functions in python is a piece of code to ask the computer to function a goal
2- a keyword is a built-in word to construct the code, so is keyword also part of function?
3- I have not found any webpages describing about how to use all the marks, and blank spaces for the right python syntax; and I can see these marks are also very important just like words; if we put them wrong, Python does not run and gives errors.

these are some of the marks I have seen in code lines:
, (comma)
. (dot or period)
' (single quote)
" (double quote)
- (short dash)
_ (long dash)
/ (forward slash)
= (equal sign)
== (double equal sign)
all kinds of brackets: () [] {}

there maybe more, but so far I could list these.

If someone help me with these questions, I really appreciate

Katherine Pray
Reply
#2
comma separates multiple values such as in a function, tuple, dictionary, or simple variable.

dot separates an object from a method, which signifies an object is doing something from a class. This is complex high level object oriented programming.

single or double quotes signify strings or character plain text values.

the dash is a subtraction sign

the underscore can help you in naming variables. When you name a variable that is 2 words, you should put an underscore between them.

the forward slash is a division sign

the equal sign is an assignment operator, example: x=5

the double equal sign is used in validating the fact that one value is equal to another, this can be used in if statements or just return statements:
return x==5 
if x==5:
    return True
Different brackets are used in different situations. A simple bracket [], is used in defining a list, parenthesis (), are used when defining a tuple, or signifying values for a function.
Reply
#3
Hello BitPythoner,

thanks a lot for your responses. Well, if you can help to give example code lines for each marks, that would be great clarity and applicable for me to use like I can imitate your lines into my lines.

thanks a lot
Katherine
Reply
#4
below link has helped me learn basics of python..
In a weeks time i've learnt to build command-line projects on python.
i hope this works for you too... Smile
https://www.w3schools.com/python/
Reply
#5
A bit of advise - don't try to learn "marks" in isolation - it doesn't make sense. They have meaning with other parts of the language. Learn the fundamentals of the language and you will learn the correct syntax, e.g. first line of the loops ends with colon, elements in containers are separated with comma, different brackets may construct different containers like tuple, list, dict, etc. and so on...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
Hi Bur
your advice are yes and no to me. In normal grammar languages, we should know both vertical and horizontal applications of the components of a sentence to get it right. What I ask is the vertical aspect, what you told me is the horizontal aspect. So I need both of them to thoroughly understand the full concepts.
Well, if someone has not yet created the explanations for the vertical part, I wish they would do some time soon.
There would definitely be other newbies having the same questions as mine.
thanks
Katherine
Reply
#7
I'm not really sure what you mean by "horizontal" and "vertical" here, but I think you're focussing too much on the little details. Focus more on the concepts and you'll naturally learn those things.
Reply
#8
There actually are definitions for all of this, but it turns out to be a very advanced topic. It sounds like you are needing some low level instruction (no insult, we all start) to help with understanding what an expression is, what a variable is, etc. rather than trying to work with the language definition (if you insist, look for the BNF for Python here)
Most of your 'marks' can be found on a pocket calculator and have the same function.

I suggest starting with this youtube that covers some of the basic concepts of programming without being specific to Python. Once you understand those concepts it will be MUCH easier to learn Python.
Reply
#9
Thumbs Up 
To Jefsummers and to ndc85430,

Well,i meant: vertical is like the breakdown of each of the marks or the dictionary version, horizontal is when we put it into the context of a whole line to make sense.

I got this from my tutor, this is the vertical explanations: I want to share here: it is neat!! Heart

#Double quotes ("") and single quotes('') are used to wrap strings:
print("Hello, world!")  # double quotes
print ('Hello, world!') # single quotes and space between the function and the parameter
# Both will output the same string.

print("It's a me, Mario!") # Wrap the string with double quotes to use the apostrophe without errors.

# print('It's a me, Mario!') Will output an error

print('It\'s a me, Mario!') # We use the escape sequence ("\") to print out special characters and be able to wrap the string with single quotes.

# Equals sign (=) is used to assign values to a variable:
num1 = 5   # spaces between operator and value
num2=2     # no spaces

# Double equals sign (==) is a comparison operator when using conditional expressions:
a = 5
b = 8
print(a == b) # Will output "False".

# Underscore sign (_) is used in variable's names:
num_3 = 99
_age = 19

# Forward slash (/) is the division operator:
print(5 / 2) # Will output 2.5

# Double fprward slash (//) is the floor division operator:
print(5 // 2) # Will output 2

# Comma (,) is used to separate variable declarations or to point the right variable we want to print out:
x, y, z = 3, 8, 15 # values are assigned respectively
sum = x + y + z
print("The sum is", sum) # Will output "The sum is 26"

# Square brackets [] are used to define arrays (you'll see that later in the course):
cars = ["Ford", "Volvo", "BMW"]

# Periods (.) are used with objects to call their respective methods:
a = [3, 1, 2, 1] # We define an array of numbers
a.reverse()      # We call the method
print(a)         # Will output ["BMW", "Volvo", "Ford"]

# Parenthesis () are used to define tuples, order of operations, generator expressions, function calls and other syntax.

# Curly brackets {} are used in dictionaries and sets.
Reply
#10
And the horizontal is the grammar to which we have been pointing toward. Interesting viewpoint. I am curious, what is your field (your name suggests a doctorate)?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Identifying keywords in text drchips 6 80,824 Mar-29-2022, 12:32 PM
Last Post: snippsat
  Customize Python Keywords for IDLE alanvers 0 1,973 Apr-03-2021, 10:56 AM
Last Post: alanvers
  Please explain uncommon way of declaring and using variable [function.variable] esphi 4 2,287 Nov-07-2020, 08:59 AM
Last Post: buran
  How to instantly add quotation marks and comma for parameters? cheers100 4 7,922 Oct-22-2020, 12:51 PM
Last Post: cheers100
  local variable 'marks' referenced before assignment Calli 3 2,277 May-25-2020, 03:15 PM
Last Post: Calli
  how to explain this function run? PY_beginner 3 2,153 Oct-04-2019, 10:09 PM
Last Post: ichabod801
  Can I search from Python, automatically and randomly generated keywords in Google? xX_Prophit_Xx 0 2,270 Sep-07-2018, 04:43 PM
Last Post: xX_Prophit_Xx

Forum Jump:

User Panel Messages

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