Guys now I'm studying Exception in python and the following concept will be covered:
SyntaxError. ValueError. try. except. NameError. else. pass. raise After I finish this I'll share for you what they're meant
❤1
SamiTech Code
What we meant by Exception and why we use it?
✅Exception means when the error occurred during the runtime.
Therefore, SyntaxError is one of the type of Exception so instead of seeing the error, it's good to use Exception handling! hey what's the error in the above code?👆 since it's programmer fault we have to recheck our code. 👀 Try it by your self and send the correct code in the comment sections.
eg: display your by accepting prompt from the user! x = int(input("How old are you? "))
print(f"I'm {x} years old) 🙆 SyntaxError: unterminated f-string literal (detected at line 3)
Therefore, SyntaxError is one of the type of Exception so instead of seeing the error, it's good to use Exception handling! hey what's the error in the above code?👆 since it's programmer fault we have to recheck our code. 👀 Try it by your self and send the correct code in the comment sections.
Use try-except to handle exception: """Write a program that accept from the user then display his age. hint: in this code programmers didn't make any mistake but it's during the user fault so, instead of seeing the error use exception handling"""👀
✅Answer
✅Answer
try:
age = int(input("How old are you? "))
print(f"I'm {age} years old. ")
except ValueError:
print("Please your age must be integer! ")
if age<0:
print("your age must be positive")
❤1
Good afternoon guys,😀
How's your study progress👈
And also don't forget to share our telegram channel for others may be the will learn what they didn't know.Let's go forward together.💪
How's your study progress👈
And also don't forget to share our telegram channel for others may be the will learn what they didn't know.
Hey there do you know the following if you know it's good, ifn't try to do it👇
after you practiced this write in the comment section what you understand! I'll prepare for you simple exam challenges Don't stop learning, have a discipline rather than motivation😁
1.Python Syntax:Your 1st program print("Let's learn together") PS C:\Users\God is with me\Desktop> cd Python
PS C:\Users\God is with me\Desktop\Python> python yourfilename.py result is : Let's learn together
2.Python Indentation:refers to the spaces at the beginning of a code line. In python this's required but like in other like Java, C++,...it's optional just it's for readability only👇. if 5 > 2:
print("Five is greater than two!") #indentations line occurred ifn't we got an indentation error
3.Python Variables:In Python, variables are created when you assign a value to it: x = 8
y = "Hello, World!" print(x) #8 print(y) #Hello, World! or to print in one line👉🏾 print("x is {x} and y is {y}") # x is 8 and y is Hello, World!
4.Comments In Python: tells what that program is doing, NB:comment isn't executed for single line use #, for multi-line use """ Multi-line comment""" #This is a single line comment.
print("Hello, World!")
after you practiced this write in the comment section what you understand! I'll prepare for you simple exam challenges
👍3
SamiTech Code pinned «Hey there do you know the following if you know it's good, ifn't try to do it👇 1.Python Syntax:Your 1st program print("Let's learn together") …»
Q1:Indentation in Python is for readability only. For each answers give your reason in the comment sections?
Anonymous Quiz
18%
True
82%
False
1.Python Output:
print(): display text or output values
any text in python must be either " double quotes or ' single quotes
print("Double qoutes") #this is correct
print('single quotes') #this is also correct
print(This will cause an error) #SyntaxError: invalid syntax.
Print without a new line:
print("Hello world!", end= " ") #end= "" ...one line
print("hey, this's the same line.")
👉🏾Hello world!, this's the same line
Print Numbers:
print(3 + 5) #8
Casting:
If you want to specify the data type of a variable this can be done with casting
a = str(5) #'5'
b = int(4) #4
c = float(2) #2.0
Get the data type:
you can get the data type of a variable with type()
x = 4
y = "Python"
print(type(x)) # <class 'int'>
print(type(y)) # <class 'str'>
Keep learning💪 don't forget your journey to #MachineLearning
Forwarded from Sanyi
just had my first podcast on the Greatness Show today!
It was an amazing experience talking about how I started programming, , and my journey as a young developer, also talked about my current project a bit.
thanks to Sofia for inviting me, the video will be out soon can’t wait to share it with you all 🤞
@thesanyi
It was an amazing experience talking about how I started programming, , and my journey as a young developer, also talked about my current project a bit.
thanks to Sofia for inviting me, the video will be out soon can’t wait to share it with you all 🤞
@thesanyi
🔥3
Btw, this's a break time😁 the all day it was just..🧑💻and now I'm tried. Take a rest, then back to your businnes🧑💻
SamiTech Code pinned «Hey guys, you should know... 👇 1.Python Output: print(): display text or output values any text in python must be either " double quotes or ' single quotes print("Double qoutes") #this is correct print('single quotes') #this is also correct print(This will…»
""" write a program that accept your name from the user, then display your name
hint use variable, input, user have to insert string """
that's easy try it and don't forget to send your code in the comment sections↩️
Now I've started Python Functions: Topic will be covered;👇
If you're ready let's study together and share idea. No matter you can post what you understand in the group discussion, in addition everyone can ask a question, here we're just friends, students don't think like in the serious place🥰 Go a head and prepare your material open code editor let's do this together 👌
Python Arguments Python *args/**kwargs python Scope Python Decorators Python Lambda Python Recursion Python Generators
If you're ready let's study together and share idea. No matter you can post what you understand in the group discussion, in addition everyone can ask a question, here we're just friends, students don't think like in the serious place🥰
...My progress here👉🏾Python Functions:
#Return Values: function can send data back to the code that called them using the return statements
Question for you don't miss it🚫 what if we code such like this👇
The Pass Statement: function definition can't be empty. if you need to create a function placeholder without any code, use the pass statement
Guess what do you say about pass by your words❓ Hey fam, Lemme see you your answer, thought in the group discussion never stop studying with me 💪
def my_func():
print("Hello this's a functions")
my_func() #calling the functions
my_func() #calling the functions
my_func() #calling the functions what you have to understand👇 def: keyword for defining functions in python my_func(): function_Name. you can just write what you want; dynamic not static😎 finally don't forget to callmy_func( ) otherwise nothing will happen
#Return Values: function can send data back to the code that called them using the return statements
def get_greeting():
return "hello, family this's python programming!"
message = get_greeting()
print(message) what you have to understand👇 return: when we use this, and when we call get_greeting() our value returned.
Question for you don't miss it🚫 what if we code such like this👇
def get_greeting():
return "hello, family this's python programming!"
get_greeting()
The Pass Statement: function definition can't be empty. if you need to create a function placeholder without any code, use the pass statement
def myfunc():
pass Nb: when you run this code nothing will appear but if you clear pass it'll show you IndentationError:
Guess what do you say about pass by your words❓ Hey fam, Lemme see you your answer, thought in the group discussion never stop studying with me 💪