Day1:
This is a super easy way of writing program compared to java.
The first line of code is to print classic "Hello World"....
Code:
print("Hello World!") --> Output : Hello World!
-*-
Super Easy right!
Code2:
print("something") --> Output : something
Explaination- ".." the double quote is used to explain computer that i wanted to print the value inside the quotes.
print is a command to the computer to print in console.
This is a error which created voluntarily to check.
The error is missing " at the end .
// Next module printing code in seperate lines.
print("Day 1 - Python Print Function")
print("The function is declared like this:")
print("print('what to print')")
Why single quote is used instead of double quotes?
It will throw a error when we use double quotes inside double quotes.
//Logic to write a single line code to print output in seperate lines.
print("Hello World!\nHelloWorld!")
// String Concat - Combine different string and the value added to other string.
print("Hello" + "Dev")
Input Function-
gets data from user and use it in code...
print("Hello" + input("What is your name?"))
hashtag is used to comment lines in python.
Counting String by getting string as a input.
len() is a predefined function which counts the value of string.
https://stackoverflow.com/questions/4967580/how-to-get-the-size-of-a-string-in-python
Here S is a variable without declaring a variable the value we get form user is stored no where if we want retrieve impossible so we are first storing it to a variable and the calling it where ever we wanted.
Concat your city and pet name and name it your music band.
city = input("what's name of the city you grew up in?")
petName = input("what's your pet's name?")
concat = print("Your Band name could be "+city+" "+petName)
GitLink : https://github.com/Saravananb15/Python/tree/day1
----****-----
Top comments (0)