DEV Community

Cover image for #1 Python Series
Saravanan B
Saravanan B

Posted on • Updated on

#1 Python Series

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.

Image description

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')")

Image description

Why single quote is used instead of double quotes?
It will throw a error when we use double quotes inside double quotes.

Image description
//Logic to write a single line code to print output in seperate lines.
print("Hello World!\nHelloWorld!")
Image description

// String Concat - Combine different string and the value added to other string.
print("Hello" + "Dev")

Image description
print("Hello"+" "+"Dev")

Input Function-
gets data from user and use it in code...
print("Hello" + input("What is your name?"))

Image description

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.
Image description
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.

Day 1 practice Excersice:
Image description

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)