If you dont know how to run python in vs code you should click here
- To comment a line use
#
- Multiline comment use
""" comment """
- Assign value in variable
variable_name = value
- To display use
print()
Example - To scan value from user use
input()
Example
- To use if condition use
if condition : code else: code
Example - To use else if condition or nested if use
if condition: code elif condition: code else: code
Example
- To use for loop use
for variable_name in array_name: print(variable_name)
Example
- Declear String
string_name = "string"
Example - Print String
print(string_name)
Example - Print targeted letter numbers in string
string_name.count('target_letter')
Example - Check length of the string
len(string_name)
Example - Print string in customise way
string_name[start:end:difference]
Example
- Write a Python program which accepts the radius of a circle from the user and compute the area
- Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them
- Write a Python program to display the first and last colours from the following list: color_list = ["Red","Green","White" ,"Black"]
- Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.
- Write a Python program to test whether a passed letter is a vowel or not.
- Write a Python program to get the n (non-negative integer) copies of the first 2 characters of a given string. Return the n copies of the whole string if the length is less than 2.
- Write a Python program to find whether a given number (accept from the user) is even or odd, print out an appropriate message to the user.
- Write a Python program to get the difference between a given number and 17, if the number is greater than 17 return double the absolute difference.
- Write a Python program to count the number 4 in a given list
- Write a Python program to get a string which is n (non-negative integer) copies of a given string.
- Write a Python program to calculate the sum of three given numbers, if the values are equal then return three times of their sum.
Hello guys hope you will like to contribute in this repository for python short notes. Your any types of contribution is acceptable so contribute. And if you like this repository then dont forget to give a star.