// Online C compiler to run C program online #include <stdio.h> #include<string.h> #include<ctype.h> int main() { // Write C code here // char str[]={'G','u','n','j','a','n','\0'}; // char str[]={'G','u','n','j','a','n'}; // char str[]={"Gunjan"}; // char str[]="Gunjan"; // char str[6]="Gunjan"; // char str[5]="Gunjan"; // will throw an error // char str[7]="Gunjan"; // char str[]="Gunjan"; // printf("%s\n",str); char str[20]; printf("Enter the value of the string:-\n"); // scanf("%s",&str); // cannot read spaces and eliminates the string after space. fgets(str,sizeof(str),stdin); printf("%s",str); str[3]='n'; printf("%c\n",str[3]); printf("%s",str); ...
thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) li=dict(name="Gunjan",age=22,cnt="India") print(li) print(thisdict["brand"]) print(thisdict['model']) print(li.get("age")) print(thisdict.keys()) print(thisdict.items()) print(thisdict.values()) thisdict['year']=2004 thisdict.update({"year":2005}) thisdict['gear']="Automatic" # thisdict.pop("gear") # thisdict.popitem() # popitem method removes the last element in the dictionary # del thisdict # it throws an error instead of this we use clear method # del thisdict['gear'] thisdict.clear() # deletes all the elements in the dictionary li2=thisdict.copy() # copy is used to copy the entire dictionary for x,y in thisdict.items(): print(f"{x} = {y}") for x,y in li2.items(): print(f"{x} = {y}") if "model" in thisdict: ...
Comments
Post a Comment