Constants Variables AND Data Types Tasks solutions
The solutions for the tasks for print are:
[https://colab.research.google.com/drive/1KrFh35UmItiS-6I7vZlxOOJh206gopat#scrollTo=LpxsOLaRQ7zW()
The solutions for the tasks for print are:
[https://colab.research.google.com/drive/1KrFh35UmItiS-6I7vZlxOOJh206gopat#scrollTo=LpxsOLaRQ7zW()
The solutions for the tasks for print are:
https://colab.research.google.com/drive/155Sla__0TMvUVnJzN4Y8YcwdZiYIMocf#scrollTo=aV5zv-IVI5UQ
13-07-2024
print()
function is a function that allows us to output to the screen
The print() function has three different uses;
we can use anyone type quote, cannot use different quote in same line
print()---------------------------#create empty line
print("jothilingam")--------------#string should print with""
print(5)------------------------#number can print without ""
print("jo""jo")--------------print without space
print("jo"+"jo")--------------print without space
answer jojo
print("jo","jo")--------------print with space
answer jo jo
print with f-strings
name = "jothi"
print(f"Hello {name}")
# Output : Hello jothi
newline escape character \n
print("jo\nthi")
jo
thi
sep
parameter
print("jo","jo",sep="_")...................sep="" is default
answer jo_jo
print("jo", "lingam", sep='thi')
answer jothilingam
end
parameter
print("jothi",end="lingam")
answer jothilingam
print("jothi",end="")----------------without space
print("lingam")
answer jothilingam
print("jothi",end=" ")----------------with space
print("lingam")
answer jothi lingam
*
parameter
print(*"jothilingam")
answer j o t h i l i n g a m
file
and flush
parameters, since these parameters are the parameters that allow us to process the files
print("hello" , "world!")
name = "syed Jafer"
print (name)
How do you print the variables name, age, and city with labels โName:โ, โAge:โ, and โCity:โ?
print ( "name:" , name , "age:" , age , "city:" , city )
How do you use an f-string to print name, age, and city in the format โName: โฆ, Age: โฆ, City: โฆโ?
print(f" name: {name} , age: {age} , city: {city}")
How do you concatenate and print the strings greeting (โHelloโ) and target (โworldโ) with a space between them?
print("hello " + "world")
How do you print three lines of text with the strings โLine1โ, โLine2โ, and โLine3โ on separate lines?
print("line1\nline2\nline3")
How do you print the string He said, "Hello, world!" including the double quotes?
print (' "hello , world!" ')
How do you print the string C:\Users\Name without escaping the backslashes?
print(r"C:\users\name")
How do you print the result of the expression 5 + 3?
print (5+3)
How do you print the strings โHelloโ and โworldโ separated by a hyphen -?
print("hello" , "world" , sep ="-")
How do you print the string โHelloโ followed by a space, and then print โworld!โ on the same line?
print("Hello" + "world!")
How do you print the value of a boolean variable is_active which is set to True?
this = True
print(this)
How do you print the string โHello โ three times in a row?
print("hello * 3")
How do you print the sentence The temperature is 22.5 degrees Celsius. using the variable temperature?
temperature = 22.5
print("the temperature is " + str(temperature) + " degrees celcius.")
How do you print name, age, and city using the .format() method in the format โName: โฆ, Age: โฆ, City: โฆโ?
print("name: {} , age:{} , city:{}". format(name,age,city))
print = เฎตเฎฟเฎณเฏเฎตเฏ
เฎตเฎฟเฎณเฏเฎตเฏ ('เฎตเฎฃเฎเฏเฎเฎฎเฏ')
I am learned python basic concept today.
share you what i learned today with example.
The name as it is print what you entered inside print function.
Ex : print("Hello")
In additionally you can pass variables like string or integer or other data types.
anime1 = "dragon ball"
anime2 = "naruto"
Ex : print("which anime do you like ? a=", anime1, " or b=", anime2)